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/SkCachingPixelRef.cpp

Issue 129423002: add SkBitmap::installPixelRef() (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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/image/SkSurface_Raster.cpp ('k') | src/lazy/SkDiscardablePixelRef.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 "SkCachingPixelRef.h" 8 #include "SkCachingPixelRef.h"
9 #include "SkScaledImageCache.h" 9 #include "SkScaledImageCache.h"
10 10
11 bool SkCachingPixelRef::Install(SkImageGenerator* generator, 11 bool SkCachingPixelRef::Install(SkImageGenerator* generator,
12 SkBitmap* dst) { 12 SkBitmap* dst) {
13 SkImageInfo info; 13 SkImageInfo info;
14 SkASSERT(dst != NULL); 14 SkASSERT(dst != NULL);
15 if ((NULL == generator) 15 if (!generator || !generator->getInfo(&info)) {
16 || !(generator->getInfo(&info))
17 || !dst->setConfig(info, 0)) {
18 SkDELETE(generator); 16 SkDELETE(generator);
19 return false; 17 return false;
20 } 18 }
21 SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef, 19 SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef,
22 (info, generator, dst->rowBytes()))); 20 (info, generator, dst->rowBytes())));
23 dst->setPixelRef(ref); 21 dst->installPixelRef(ref);
24 return true; 22 return true;
25 } 23 }
26 24
27 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info, 25 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info,
28 SkImageGenerator* generator, 26 SkImageGenerator* generator,
29 size_t rowBytes) 27 size_t rowBytes)
30 : INHERITED(info) 28 : INHERITED(info)
31 , fImageGenerator(generator) 29 , fImageGenerator(generator)
32 , fErrorInDecoding(false) 30 , fErrorInDecoding(false)
33 , fScaledCacheId(NULL) 31 , fScaledCacheId(NULL)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 rec->fColorTable = NULL; 86 rec->fColorTable = NULL;
89 rec->fRowBytes = bitmap.rowBytes(); 87 rec->fRowBytes = bitmap.rowBytes();
90 return true; 88 return true;
91 } 89 }
92 90
93 void SkCachingPixelRef::onUnlockPixels() { 91 void SkCachingPixelRef::onUnlockPixels() {
94 SkASSERT(fScaledCacheId != NULL); 92 SkASSERT(fScaledCacheId != NULL);
95 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach eId)); 93 SkScaledImageCache::Unlock( static_cast<SkScaledImageCache::ID*>(fScaledCach eId));
96 fScaledCacheId = NULL; 94 fScaledCacheId = NULL;
97 } 95 }
OLDNEW
« no previous file with comments | « src/image/SkSurface_Raster.cpp ('k') | src/lazy/SkDiscardablePixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698