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

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

Issue 1305453007: SkImage method for detecting lazy decoding (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review comments Created 5 years, 4 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/image/SkImage_Base.h ('k') | src/lazy/SkCachingPixelRef.h » ('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 2012 Google Inc. 2 * Copyright 2012 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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 , fBitmap(bm) 86 , fBitmap(bm)
87 { 87 {
88 if (bm.pixelRef()->isPreLocked()) { 88 if (bm.pixelRef()->isPreLocked()) {
89 // we only preemptively lock if there is no chance of triggering som ething expensive 89 // we only preemptively lock if there is no chance of triggering som ething expensive
90 // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already. 90 // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already.
91 fBitmap.lockPixels(); 91 fBitmap.lockPixels();
92 } 92 }
93 SkASSERT(fBitmap.isImmutable()); 93 SkASSERT(fBitmap.isImmutable());
94 } 94 }
95 95
96 bool onIsLazyGenerated() const override {
97 return fBitmap.pixelRef() && fBitmap.pixelRef()->isLazyGenerated();
98 }
99
96 private: 100 private:
97 SkImage_Raster() : INHERITED(0, 0, kNeedNewImageUniqueID, NULL) { 101 SkImage_Raster() : INHERITED(0, 0, kNeedNewImageUniqueID, NULL) {
98 fBitmap.setImmutable(); 102 fBitmap.setImmutable();
99 } 103 }
100 104
101 SkBitmap fBitmap; 105 SkBitmap fBitmap;
102 106
103 typedef SkImage_Base INHERITED; 107 typedef SkImage_Base INHERITED;
104 }; 108 };
105 109
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // pixelref since the caller might call setImmutable() themselves 285 // pixelref since the caller might call setImmutable() themselves
282 // (thus changing our state). 286 // (thus changing our state).
283 if (fBitmap.isImmutable()) { 287 if (fBitmap.isImmutable()) {
284 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes()); 288 bitmap->setInfo(fBitmap.info(), fBitmap.rowBytes());
285 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin()); 289 bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
286 return true; 290 return true;
287 } 291 }
288 } 292 }
289 return this->INHERITED::onAsLegacyBitmap(bitmap, mode); 293 return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
290 } 294 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Base.h ('k') | src/lazy/SkCachingPixelRef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698