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

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

Issue 68973005: Expand pixelref to return SkImageInfo and rowbytes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: new convention: require SkImageInfo in constructor 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
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(SkData* data) : fData(data) { 12 SkDataPixelRef::SkDataPixelRef(const SkImageInfo& info,
13 SkData* data, size_t rowBytes)
14 : INHERITED(info)
15 , fData(data)
16 , fRB(rowBytes)
17 {
13 fData->ref(); 18 fData->ref();
14 this->setPreLocked(const_cast<void*>(fData->data()), NULL); 19 this->setPreLocked(const_cast<void*>(fData->data()), rowBytes, NULL);
15 } 20 }
16 21
17 SkDataPixelRef::~SkDataPixelRef() { 22 SkDataPixelRef::~SkDataPixelRef() {
18 fData->unref(); 23 fData->unref();
19 } 24 }
20 25
21 void* SkDataPixelRef::onLockPixels(SkColorTable** ct) { 26 bool SkDataPixelRef::onNewLockPixels(LockRec* rec) {
22 *ct = NULL; 27 rec->fPixels = const_cast<void*>(fData->data());
23 return const_cast<void*>(fData->data()); 28 rec->fColorTable = NULL;
29 rec->fRowBytes = fRB;
30 return true;
24 } 31 }
25 32
26 void SkDataPixelRef::onUnlockPixels() { 33 void SkDataPixelRef::onUnlockPixels() {
27 // nothing to do 34 // nothing to do
28 } 35 }
29 36
30 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { 37 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
31 this->INHERITED::flatten(buffer); 38 this->INHERITED::flatten(buffer);
39
32 buffer.writeDataAsByteArray(fData); 40 buffer.writeDataAsByteArray(fData);
41 buffer.write32(fRB);
33 } 42 }
34 43
35 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) 44 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer)
36 : INHERITED(buffer, NULL) { 45 : INHERITED(buffer, NULL)
46 {
37 fData = buffer.readByteArrayAsData(); 47 fData = buffer.readByteArrayAsData();
38 this->setPreLocked(const_cast<void*>(fData->data()), NULL); 48 fRB = buffer.read32();
49 this->setPreLocked(const_cast<void*>(fData->data()), fRB, NULL);
39 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698