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

Side by Side Diff: src/lazy/SkDiscardablePixelRef.cpp

Issue 99303003: SkDiscardablePixelRef objects are now marked immutable. (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 | « include/core/SkImageGenerator.h ('k') | no next file » | 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 2013 Google Inc. 2 * Copyright 2013 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 "SkDiscardablePixelRef.h" 8 #include "SkDiscardablePixelRef.h"
9 #include "SkDiscardableMemory.h" 9 #include "SkDiscardableMemory.h"
10 10
11 SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator, 11 SkDiscardablePixelRef::SkDiscardablePixelRef(SkImageGenerator* generator,
12 const SkImageInfo& info, 12 const SkImageInfo& info,
13 size_t size, 13 size_t size,
14 size_t rowBytes) 14 size_t rowBytes)
15 : fGenerator(generator) 15 : fGenerator(generator)
16 , fInfo(info) 16 , fInfo(info)
17 , fSize(size) 17 , fSize(size)
18 , fRowBytes(rowBytes) 18 , fRowBytes(rowBytes)
19 , fDiscardableMemory(NULL) { 19 , fDiscardableMemory(NULL) {
20 SkASSERT(fGenerator != NULL); 20 SkASSERT(fGenerator != NULL);
21 SkASSERT(fSize > 0); 21 SkASSERT(fSize > 0);
22 SkASSERT(fRowBytes > 0); 22 SkASSERT(fRowBytes > 0);
23 // The SkImageGenerator contract requires fGenerator to always
24 // decode the same image on each call to getPixels().
25 this->setImmutable();
23 } 26 }
24 27
25 SkDiscardablePixelRef::~SkDiscardablePixelRef() { 28 SkDiscardablePixelRef::~SkDiscardablePixelRef() {
26 SkDELETE(fGenerator); 29 SkDELETE(fGenerator);
27 } 30 }
28 31
29 void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) { 32 void* SkDiscardablePixelRef::onLockPixels(SkColorTable**) {
30 if (fDiscardableMemory != NULL) { 33 if (fDiscardableMemory != NULL) {
31 if (fDiscardableMemory->lock()) { 34 if (fDiscardableMemory->lock()) {
32 return fDiscardableMemory->data(); 35 return fDiscardableMemory->data();
(...skipping 26 matching lines...) Expand all
59 SkDELETE(generator); 62 SkDELETE(generator);
60 return false; 63 return false;
61 } 64 }
62 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, 65 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
63 (generator, info, 66 (generator, info,
64 dst->getSize(), 67 dst->getSize(),
65 dst->rowBytes()))); 68 dst->rowBytes())));
66 dst->setPixelRef(ref); 69 dst->setPixelRef(ref);
67 return true; 70 return true;
68 } 71 }
OLDNEW
« no previous file with comments | « include/core/SkImageGenerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698