OLD | NEW |
| (Empty) |
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 #include "SkFlattenableBuffers.h" | |
11 | |
12 SkDataPixelRef::SkDataPixelRef(const SkImageInfo& info, SkData* data) | |
13 : INHERITED(info) | |
14 , fData(data) | |
15 { | |
16 fData->ref(); | |
17 this->setPreLocked(const_cast<void*>(fData->data()), NULL); | |
18 } | |
19 | |
20 SkDataPixelRef::~SkDataPixelRef() { | |
21 fData->unref(); | |
22 } | |
23 | |
24 void* SkDataPixelRef::onLockPixels(SkColorTable** ct) { | |
25 *ct = NULL; | |
26 return const_cast<void*>(fData->data()); | |
27 } | |
28 | |
29 void SkDataPixelRef::onUnlockPixels() { | |
30 // nothing to do | |
31 } | |
32 | |
33 size_t SkDataPixelRef::getAllocatedSizeInBytes() const { | |
34 return fData ? fData->size() : 0; | |
35 } | |
36 | |
37 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { | |
38 this->INHERITED::flatten(buffer); | |
39 buffer.writeDataAsByteArray(fData); | |
40 } | |
41 | |
42 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) | |
43 : INHERITED(buffer, NULL) { | |
44 fData = buffer.readByteArrayAsData(); | |
45 this->setPreLocked(const_cast<void*>(fData->data()), NULL); | |
46 } | |
OLD | NEW |