Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: src/image/SkDataPixelRef.cpp

Issue 108513003: Revert "PixelRef now returns (nearly) everything that is currently in SkBitmap. The goal is to refa… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/image/SkDataPixelRef.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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(const SkImageInfo& info, 12 SkDataPixelRef::SkDataPixelRef(SkData* data) : fData(data) {
13 SkData* data, size_t rowBytes)
14 : INHERITED(info)
15 , fData(data)
16 , fRB(rowBytes)
17 {
18 fData->ref(); 13 fData->ref();
19 this->setPreLocked(const_cast<void*>(fData->data()), rowBytes, NULL); 14 this->setPreLocked(const_cast<void*>(fData->data()), NULL);
20 } 15 }
21 16
22 SkDataPixelRef::~SkDataPixelRef() { 17 SkDataPixelRef::~SkDataPixelRef() {
23 fData->unref(); 18 fData->unref();
24 } 19 }
25 20
26 bool SkDataPixelRef::onNewLockPixels(LockRec* rec) { 21 void* SkDataPixelRef::onLockPixels(SkColorTable** ct) {
27 rec->fPixels = const_cast<void*>(fData->data()); 22 *ct = NULL;
28 rec->fColorTable = NULL; 23 return const_cast<void*>(fData->data());
29 rec->fRowBytes = fRB;
30 return true;
31 } 24 }
32 25
33 void SkDataPixelRef::onUnlockPixels() { 26 void SkDataPixelRef::onUnlockPixels() {
34 // nothing to do 27 // nothing to do
35 } 28 }
36 29
37 size_t SkDataPixelRef::getAllocatedSizeInBytes() const { 30 size_t SkDataPixelRef::getAllocatedSizeInBytes() const {
38 return fData ? fData->size() : 0; 31 return fData ? fData->size() : 0;
39 } 32 }
40 33
41 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { 34 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
42 this->INHERITED::flatten(buffer); 35 this->INHERITED::flatten(buffer);
43
44 buffer.writeDataAsByteArray(fData); 36 buffer.writeDataAsByteArray(fData);
45 buffer.write32(fRB);
46 } 37 }
47 38
48 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) 39 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer)
49 : INHERITED(buffer, NULL) 40 : INHERITED(buffer, NULL) {
50 {
51 fData = buffer.readByteArrayAsData(); 41 fData = buffer.readByteArrayAsData();
52 fRB = buffer.read32(); 42 this->setPreLocked(const_cast<void*>(fData->data()), NULL);
53 this->setPreLocked(const_cast<void*>(fData->data()), fRB, NULL);
54 } 43 }
OLDNEW
« no previous file with comments | « src/image/SkDataPixelRef.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698