LCOV - app.info - gfx/skia/src/core/SkMallocPixelRef.cpp

LCOV - code coverage report
| Current view: | directory - gfx/skia/src/core - SkMallocPixelRef.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 37 | 1 | 2.7 %
| Date: | 2012-07-07 | Functions: | 10 | 2 | 20.0 %

           1                 :
           2                 : /*
           3                 :  * Copyright 2011 Google Inc.
           4                 :  *
           5                 :  * Use of this source code is governed by a BSD-style license that can be
           6                 :  * found in the LICENSE file.
           7                 :  */
           8                 : #include "SkMallocPixelRef.h"
           9                 : #include "SkBitmap.h"
          10                 : #include "SkFlattenable.h"
          11                 :
          12               0 : SkMallocPixelRef::SkMallocPixelRef(void* storage, size_t size,
          13               0 :                                    SkColorTable* ctable) {
          14               0 :     if (NULL == storage) {
          15               0 :         storage = sk_malloc_throw(size);
          16                 :     }
          17               0 :     fStorage = storage;
          18               0 :     fSize = size;
          19               0 :     fCTable = ctable;
          20               0 :     SkSafeRef(ctable);
          21               0 : }
          22                 :
          23               0 : SkMallocPixelRef::~SkMallocPixelRef() {
          24               0 :     SkSafeUnref(fCTable);
          25               0 :     sk_free(fStorage);
          26               0 : }
          27                 :
          28               0 : void* SkMallocPixelRef::onLockPixels(SkColorTable** ct) {
          29               0 :     *ct = fCTable;
          30               0 :     return fStorage;
          31                 : }
          32                 :
          33               0 : void SkMallocPixelRef::onUnlockPixels() {
          34                 :     // nothing to do
          35               0 : }
          36                 :
          37               0 : void SkMallocPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
          38               0 :     this->INHERITED::flatten(buffer);
          39                 :
          40               0 :     buffer.write32(fSize);
          41               0 :     buffer.writePad(fStorage, fSize);
          42               0 :     if (fCTable) {
          43               0 :         buffer.writeBool(true);
          44               0 :         fCTable->flatten(buffer);
          45                 :     } else {
          46               0 :         buffer.writeBool(false);
          47                 :     }
          48               0 : }
          49                 :
          50               0 : SkMallocPixelRef::SkMallocPixelRef(SkFlattenableReadBuffer& buffer)
          51               0 :         : INHERITED(buffer, NULL) {
          52               0 :     fSize = buffer.readU32();
          53               0 :     fStorage = sk_malloc_throw(fSize);
          54               0 :     buffer.read(fStorage, fSize);
          55               0 :     if (buffer.readBool()) {
          56               0 :         fCTable = SkNEW_ARGS(SkColorTable, (buffer));
          57                 :     } else {
          58               0 :         fCTable = NULL;
          59                 :     }
          60               0 : }
          61                 :
          62            2928 : SK_DEFINE_PIXEL_REF_REGISTRAR(SkMallocPixelRef)

Generated by: LCOV version 1.7