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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/images/bmpdecoderhelper.cpp ('k') | src/lazy/SkDiscardableMemoryPool.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 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 "SkBitmapCache.h" 9 #include "SkBitmapCache.h"
10 #include "SkRect.h" 10 #include "SkRect.h"
11 11
12 bool SkCachingPixelRef::Install(SkImageGenerator* generator, 12 bool SkCachingPixelRef::Install(SkImageGenerator* generator,
13 SkBitmap* dst) { 13 SkBitmap* dst) {
14 SkASSERT(dst != NULL); 14 SkASSERT(dst != nullptr);
15 if (NULL == generator) { 15 if (nullptr == generator) {
16 return false; 16 return false;
17 } 17 }
18 const SkImageInfo info = generator->getInfo(); 18 const SkImageInfo info = generator->getInfo();
19 if (!dst->setInfo(info)) { 19 if (!dst->setInfo(info)) {
20 delete generator; 20 delete generator;
21 return false; 21 return false;
22 } 22 }
23 SkAutoTUnref<SkCachingPixelRef> ref(new SkCachingPixelRef(info, generator, d st->rowBytes())); 23 SkAutoTUnref<SkCachingPixelRef> ref(new SkCachingPixelRef(info, generator, d st->rowBytes()));
24 dst->setPixelRef(ref); 24 dst->setPixelRef(ref);
25 return true; 25 return true;
26 } 26 }
27 27
28 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info, 28 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info,
29 SkImageGenerator* generator, 29 SkImageGenerator* generator,
30 size_t rowBytes) 30 size_t rowBytes)
31 : INHERITED(info) 31 : INHERITED(info)
32 , fImageGenerator(generator) 32 , fImageGenerator(generator)
33 , fErrorInDecoding(false) 33 , fErrorInDecoding(false)
34 , fRowBytes(rowBytes) { 34 , fRowBytes(rowBytes) {
35 SkASSERT(fImageGenerator != NULL); 35 SkASSERT(fImageGenerator != nullptr);
36 } 36 }
37 SkCachingPixelRef::~SkCachingPixelRef() { 37 SkCachingPixelRef::~SkCachingPixelRef() {
38 delete fImageGenerator; 38 delete fImageGenerator;
39 // Assert always unlock before unref. 39 // Assert always unlock before unref.
40 } 40 }
41 41
42 bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { 42 bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) {
43 if (fErrorInDecoding) { 43 if (fErrorInDecoding) {
44 return false; // don't try again. 44 return false; // don't try again.
45 } 45 }
46 46
47 const SkImageInfo& info = this->info(); 47 const SkImageInfo& info = this->info();
48 if (!SkBitmapCache::Find( 48 if (!SkBitmapCache::Find(
49 this->getGenerationID(), info.bounds(), &fLockedBitmap)) { 49 this->getGenerationID(), info.bounds(), &fLockedBitmap)) {
50 // Cache has been purged, must re-decode. 50 // Cache has been purged, must re-decode.
51 if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) { 51 if (!fLockedBitmap.tryAllocPixels(info, fRowBytes)) {
52 fErrorInDecoding = true; 52 fErrorInDecoding = true;
53 return false; 53 return false;
54 } 54 }
55 if (!fImageGenerator->getPixels(info, fLockedBitmap.getPixels(), fRowByt es)) { 55 if (!fImageGenerator->getPixels(info, fLockedBitmap.getPixels(), fRowByt es)) {
56 fErrorInDecoding = true; 56 fErrorInDecoding = true;
57 return false; 57 return false;
58 } 58 }
59 fLockedBitmap.setImmutable(); 59 fLockedBitmap.setImmutable();
60 SkBitmapCache::Add(this, info.bounds(), fLockedBitmap); 60 SkBitmapCache::Add(this, info.bounds(), fLockedBitmap);
61 } 61 }
62 62
63 // Now bitmap should contain a concrete PixelRef of the decoded image. 63 // Now bitmap should contain a concrete PixelRef of the decoded image.
64 void* pixels = fLockedBitmap.getPixels(); 64 void* pixels = fLockedBitmap.getPixels();
65 SkASSERT(pixels != NULL); 65 SkASSERT(pixels != nullptr);
66 rec->fPixels = pixels; 66 rec->fPixels = pixels;
67 rec->fColorTable = NULL; 67 rec->fColorTable = nullptr;
68 rec->fRowBytes = fLockedBitmap.rowBytes(); 68 rec->fRowBytes = fLockedBitmap.rowBytes();
69 return true; 69 return true;
70 } 70 }
71 71
72 void SkCachingPixelRef::onUnlockPixels() { 72 void SkCachingPixelRef::onUnlockPixels() {
73 fLockedBitmap.reset(); 73 fLockedBitmap.reset();
74 } 74 }
OLDNEW
« no previous file with comments | « src/images/bmpdecoderhelper.cpp ('k') | src/lazy/SkDiscardableMemoryPool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698