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

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

Issue 1017293002: guarded change to SkImageGenerator to make getInfo() const (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/lazy/SkCachingPixelRef.cpp ('k') | src/ports/SkImageGenerator_skia.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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return true; 102 return true;
103 } 103 }
104 104
105 void SkDiscardablePixelRef::onUnlockPixels() { 105 void SkDiscardablePixelRef::onUnlockPixels() {
106 fDiscardableMemory->unlock(); 106 fDiscardableMemory->unlock();
107 fDiscardableMemoryIsLocked = false; 107 fDiscardableMemoryIsLocked = false;
108 } 108 }
109 109
110 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst, 110 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst,
111 SkDiscardableMemory::Factory* factory) { 111 SkDiscardableMemory::Factory* factory) {
112 SkImageInfo info;
113 SkAutoTDelete<SkImageGenerator> autoGenerator(generator); 112 SkAutoTDelete<SkImageGenerator> autoGenerator(generator);
114 if ((NULL == autoGenerator.get()) 113 if (NULL == autoGenerator.get()) {
115 || (!autoGenerator->getInfo(&info)) 114 return false;
116 || info.isEmpty() 115 }
117 || (!dst->setInfo(info))) { 116 SkImageInfo info = autoGenerator->getInfo();
117 if (info.isEmpty() || !dst->setInfo(info)) {
118 return false; 118 return false;
119 } 119 }
120 // Since dst->setInfo() may have changed/fixed-up info, we copy it back from that bitmap 120 // Since dst->setInfo() may have changed/fixed-up info, we copy it back from that bitmap
121 info = dst->info(); 121 info = dst->info();
122 122
123 SkASSERT(info.colorType() != kUnknown_SkColorType); 123 SkASSERT(info.colorType() != kUnknown_SkColorType);
124 if (dst->empty()) { // Use a normal pixelref. 124 if (dst->empty()) { // Use a normal pixelref.
125 return dst->tryAllocPixels(); 125 return dst->tryAllocPixels();
126 } 126 }
127 SkAutoTUnref<SkDiscardablePixelRef> ref( 127 SkAutoTUnref<SkDiscardablePixelRef> ref(
128 SkNEW_ARGS(SkDiscardablePixelRef, 128 SkNEW_ARGS(SkDiscardablePixelRef,
129 (info, autoGenerator.detach(), dst->rowBytes(), factory))); 129 (info, autoGenerator.detach(), dst->rowBytes(), factory)));
130 dst->setPixelRef(ref); 130 dst->setPixelRef(ref);
131 return true; 131 return true;
132 } 132 }
133 133
134 // These are the public API 134 // These are the public API
135 135
136 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) { 136 bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, SkBitmap* dst) {
137 return SkInstallDiscardablePixelRef(generator, dst, NULL); 137 return SkInstallDiscardablePixelRef(generator, dst, NULL);
138 } 138 }
139 139
140 bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) { 140 bool SkInstallDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
141 SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded); 141 SkImageGenerator* generator = SkImageGenerator::NewFromData(encoded);
142 return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : fals e; 142 return generator ? SkInstallDiscardablePixelRef(generator, dst, NULL) : fals e;
143 } 143 }
OLDNEW
« no previous file with comments | « src/lazy/SkCachingPixelRef.cpp ('k') | src/ports/SkImageGenerator_skia.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698