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

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

Issue 92793002: Fixed bad bitmap size crashes (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Changed getSize name to getAllocatedSizeInBytes 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(SkData* data) : fData(data) {
13 fData->ref(); 13 fData->ref();
14 this->setPreLocked(const_cast<void*>(fData->data()), NULL); 14 this->setPreLocked(const_cast<void*>(fData->data()), NULL);
15 } 15 }
16 16
17 SkDataPixelRef::~SkDataPixelRef() { 17 SkDataPixelRef::~SkDataPixelRef() {
18 fData->unref(); 18 fData->unref();
19 } 19 }
20 20
21 void* SkDataPixelRef::onLockPixels(SkColorTable** ct) { 21 void* SkDataPixelRef::onLockPixels(SkColorTable** ct) {
22 *ct = NULL; 22 *ct = NULL;
23 return const_cast<void*>(fData->data()); 23 return const_cast<void*>(fData->data());
24 } 24 }
25 25
26 void SkDataPixelRef::onUnlockPixels() { 26 void SkDataPixelRef::onUnlockPixels() {
27 // nothing to do 27 // nothing to do
28 } 28 }
29 29
30 size_t SkDataPixelRef::getAllocatedSizeInBytes() const {
31 return fData ? fData->size() : 0;
32 }
33
30 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const { 34 void SkDataPixelRef::flatten(SkFlattenableWriteBuffer& buffer) const {
31 this->INHERITED::flatten(buffer); 35 this->INHERITED::flatten(buffer);
32 buffer.writeDataAsByteArray(fData); 36 buffer.writeDataAsByteArray(fData);
33 } 37 }
34 38
35 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer) 39 SkDataPixelRef::SkDataPixelRef(SkFlattenableReadBuffer& buffer)
36 : INHERITED(buffer, NULL) { 40 : INHERITED(buffer, NULL) {
37 fData = buffer.readByteArrayAsData(); 41 fData = buffer.readByteArrayAsData();
38 this->setPreLocked(const_cast<void*>(fData->data()), NULL); 42 this->setPreLocked(const_cast<void*>(fData->data()), NULL);
39 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698