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

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

Issue 106883006: Add a release procedure to SkMallocPixelRef; remove SkDataPixelRef (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 11 months 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
(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 }
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