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

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

Issue 93703004: Change SkDecodingImageGenerator API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebased 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/lazy/SkDiscardablePixelRef.h ('k') | tests/CachedDecodingPixelRefTest.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 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 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return pixels; 65 return pixels;
66 } 66 }
67 void SkDiscardablePixelRef::onUnlockPixels() { 67 void SkDiscardablePixelRef::onUnlockPixels() {
68 fDiscardableMemory->unlock(); 68 fDiscardableMemory->unlock();
69 } 69 }
70 70
71 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, 71 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
72 SkBitmap* dst, 72 SkBitmap* dst,
73 SkDiscardableMemory::Factory* factory) { 73 SkDiscardableMemory::Factory* factory) {
74 SkImageInfo info; 74 SkImageInfo info;
75 SkASSERT(generator != NULL); 75 SkAutoTDelete<SkImageGenerator> autoGenerator(generator);
76 if ((NULL == generator) 76 if ((NULL == autoGenerator.get())
77 || (!generator->getInfo(&info)) 77 || (!autoGenerator->getInfo(&info))
78 || (!dst->setConfig(info, 0))) { 78 || (!dst->setConfig(info, 0))) {
79 SkDELETE(generator);
80 return false; 79 return false;
81 } 80 }
82 SkASSERT(dst->config() != SkBitmap::kNo_Config); 81 SkASSERT(dst->config() != SkBitmap::kNo_Config);
83 if (dst->empty()) { // Use a normal pixelref. 82 if (dst->empty()) { // Use a normal pixelref.
84 SkDELETE(generator); // Do not need this anymore.
85 return dst->allocPixels(NULL, NULL); 83 return dst->allocPixels(NULL, NULL);
86 } 84 }
87 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, 85 SkAutoTUnref<SkDiscardablePixelRef> ref(
88 (info, generator, dst->rowBytes(), factory))); 86 SkNEW_ARGS(SkDiscardablePixelRef,
87 (info, autoGenerator.detach(), dst->rowBytes(), factory)));
89 dst->setPixelRef(ref); 88 dst->setPixelRef(ref);
90 return true; 89 return true;
91 } 90 }
OLDNEW
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.h ('k') | tests/CachedDecodingPixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698