OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDataPixelRef.h" | 8 #include "SkDataPixelRef.h" |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkFlattenableBuffers.h" | 10 #include "SkFlattenableBuffers.h" |
11 | 11 |
12 SkDataPixelRef::SkDataPixelRef(SkData* data) : fData(data) { | 12 SkDataPixelRef::SkDataPixelRef(const SkImageInfo& info, SkData* data) |
| 13 : INHERITED(info) |
| 14 , fData(data) |
| 15 { |
13 fData->ref(); | 16 fData->ref(); |
14 this->setPreLocked(const_cast<void*>(fData->data()), NULL); | 17 this->setPreLocked(const_cast<void*>(fData->data()), NULL); |
15 } | 18 } |
16 | 19 |
17 SkDataPixelRef::~SkDataPixelRef() { | 20 SkDataPixelRef::~SkDataPixelRef() { |
18 fData->unref(); | 21 fData->unref(); |
19 } | 22 } |
20 | 23 |
21 void* SkDataPixelRef::onLockPixels(SkColorTable** ct) { | 24 void* SkDataPixelRef::onLockPixels(SkColorTable** ct) { |
22 *ct = NULL; | 25 *ct = NULL; |
(...skipping 11 matching lines...) Expand all Loading... |
34 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { | 37 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { |
35 this->INHERITED::flatten(buffer); | 38 this->INHERITED::flatten(buffer); |
36 buffer.writeDataAsByteArray(fData); | 39 buffer.writeDataAsByteArray(fData); |
37 } | 40 } |
38 | 41 |
39 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) | 42 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) |
40 : INHERITED(buffer, NULL) { | 43 : INHERITED(buffer, NULL) { |
41 fData = buffer.readByteArrayAsData(); | 44 fData = buffer.readByteArrayAsData(); |
42 this->setPreLocked(const_cast<void*>(fData->data()), NULL); | 45 this->setPreLocked(const_cast<void*>(fData->data()), NULL); |
43 } | 46 } |
OLD | NEW |