reed@google.com | f6627b7 | 2012-07-27 18:02:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkDataPixelRef.h" |
| 9 | #include "SkData.h" |
| 10 | |
| 11 | SkDataPixelRef::SkDataPixelRef(SkData* data) : fData(data) { |
| 12 | fData->ref(); |
| 13 | this->setPreLocked(const_cast<void*>(fData->data()), NULL); |
| 14 | } |
| 15 | |
| 16 | SkDataPixelRef::~SkDataPixelRef() { |
| 17 | fData->unref(); |
| 18 | } |
| 19 | |
| 20 | void* SkDataPixelRef::onLockPixels(SkColorTable** ct) { |
| 21 | *ct = NULL; |
| 22 | return const_cast<void*>(fData->data()); |
| 23 | } |
| 24 | |
| 25 | void SkDataPixelRef::onUnlockPixels() { |
| 26 | // nothing to do |
| 27 | } |
| 28 | |
| 29 | void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { |
| 30 | this->INHERITED::flatten(buffer); |
| 31 | |
| 32 | // fData->flatten(buffer); |
| 33 | } |
| 34 | |
| 35 | SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) |
| 36 | : INHERITED(buffer, NULL) { |
| 37 | |
| 38 | // fData = buffer.readData(); |
| 39 | this->setPreLocked(const_cast<void*>(fData->data()), NULL); |
| 40 | } |
| 41 | |
| 42 | SK_DEFINE_FLATTENABLE_REGISTRAR(SkDataPixelRef) |