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

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

Issue 93673005: Revert of ensure that we call onUnlock only when we onLock succeeded (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 | « src/lazy/SkCachingPixelRef.cpp ('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 #include "SkImageGenerator.h" 10 #include "SkImageGenerator.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 if (NULL == fDiscardableMemory) { 51 if (NULL == fDiscardableMemory) {
52 return NULL; // Memory allocation failed. 52 return NULL; // Memory allocation failed.
53 } 53 }
54 void* pixels = fDiscardableMemory->data(); 54 void* pixels = fDiscardableMemory->data();
55 if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) { 55 if (!fGenerator->getPixels(fInfo, pixels, fRowBytes)) {
56 return NULL; // TODO(halcanary) Find out correct thing to do. 56 return NULL; // TODO(halcanary) Find out correct thing to do.
57 } 57 }
58 return pixels; 58 return pixels;
59 } 59 }
60 void SkDiscardablePixelRef::onUnlockPixels() { 60 void SkDiscardablePixelRef::onUnlockPixels() {
61 fDiscardableMemory->unlock(); 61 if (fDiscardableMemory != NULL) {
62 fDiscardableMemory->unlock();
63 }
62 } 64 }
63 65
64 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, 66 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
65 SkBitmap* dst, 67 SkBitmap* dst,
66 SkDiscardableMemory::Factory* factory) { 68 SkDiscardableMemory::Factory* factory) {
67 SkImageInfo info; 69 SkImageInfo info;
68 SkASSERT(generator != NULL); 70 SkASSERT(generator != NULL);
69 if ((NULL == generator) 71 if ((NULL == generator)
70 || (!generator->getInfo(&info)) 72 || (!generator->getInfo(&info))
71 || (!dst->setConfig(info, 0))) { 73 || (!dst->setConfig(info, 0))) {
72 SkDELETE(generator); 74 SkDELETE(generator);
73 return false; 75 return false;
74 } 76 }
75 SkASSERT(dst->config() != SkBitmap::kNo_Config); 77 SkASSERT(dst->config() != SkBitmap::kNo_Config);
76 if (dst->empty()) { // Use a normal pixelref. 78 if (dst->empty()) { // Use a normal pixelref.
77 SkDELETE(generator); // Do not need this anymore. 79 SkDELETE(generator); // Do not need this anymore.
78 return dst->allocPixels(NULL, NULL); 80 return dst->allocPixels(NULL, NULL);
79 } 81 }
80 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef, 82 SkAutoTUnref<SkDiscardablePixelRef> ref(SkNEW_ARGS(SkDiscardablePixelRef,
81 (generator, info, 83 (generator, info,
82 dst->getSize(), 84 dst->getSize(),
83 dst->rowBytes(), 85 dst->rowBytes(),
84 factory))); 86 factory)));
85 dst->setPixelRef(ref); 87 dst->setPixelRef(ref);
86 return true; 88 return true;
87 } 89 }
OLDNEW
« no previous file with comments | « src/lazy/SkCachingPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698