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

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

Issue 1316123003: Style Change: SkNEW->new; SkDELETE->delete (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-26 (Wednesday) 15:59:00 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/lazy/SkCachingPixelRef.h ('k') | src/lazy/SkDiscardableMemoryPool.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 "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 != NULL);
15 if (NULL == generator) { 15 if (NULL == 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 SkDELETE(generator); 20 delete generator;
21 return false; 21 return false;
22 } 22 }
23 SkAutoTUnref<SkCachingPixelRef> ref(SkNEW_ARGS(SkCachingPixelRef, 23 SkAutoTUnref<SkCachingPixelRef> ref(new SkCachingPixelRef(info, generator, d st->rowBytes()));
24 (info, generator, dst->rowBytes())));
25 dst->setPixelRef(ref); 24 dst->setPixelRef(ref);
26 return true; 25 return true;
27 } 26 }
28 27
29 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info, 28 SkCachingPixelRef::SkCachingPixelRef(const SkImageInfo& info,
30 SkImageGenerator* generator, 29 SkImageGenerator* generator,
31 size_t rowBytes) 30 size_t rowBytes)
32 : INHERITED(info) 31 : INHERITED(info)
33 , fImageGenerator(generator) 32 , fImageGenerator(generator)
34 , fErrorInDecoding(false) 33 , fErrorInDecoding(false)
35 , fRowBytes(rowBytes) { 34 , fRowBytes(rowBytes) {
36 SkASSERT(fImageGenerator != NULL); 35 SkASSERT(fImageGenerator != NULL);
37 } 36 }
38 SkCachingPixelRef::~SkCachingPixelRef() { 37 SkCachingPixelRef::~SkCachingPixelRef() {
39 SkDELETE(fImageGenerator); 38 delete fImageGenerator;
40 // Assert always unlock before unref. 39 // Assert always unlock before unref.
41 } 40 }
42 41
43 bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) { 42 bool SkCachingPixelRef::onNewLockPixels(LockRec* rec) {
44 if (fErrorInDecoding) { 43 if (fErrorInDecoding) {
45 return false; // don't try again. 44 return false; // don't try again.
46 } 45 }
47 46
48 const SkImageInfo& info = this->info(); 47 const SkImageInfo& info = this->info();
49 if (!SkBitmapCache::Find( 48 if (!SkBitmapCache::Find(
(...skipping 16 matching lines...) Expand all
66 SkASSERT(pixels != NULL); 65 SkASSERT(pixels != NULL);
67 rec->fPixels = pixels; 66 rec->fPixels = pixels;
68 rec->fColorTable = NULL; 67 rec->fColorTable = NULL;
69 rec->fRowBytes = fLockedBitmap.rowBytes(); 68 rec->fRowBytes = fLockedBitmap.rowBytes();
70 return true; 69 return true;
71 } 70 }
72 71
73 void SkCachingPixelRef::onUnlockPixels() { 72 void SkCachingPixelRef::onUnlockPixels() {
74 fLockedBitmap.reset(); 73 fLockedBitmap.reset();
75 } 74 }
OLDNEW
« no previous file with comments | « src/lazy/SkCachingPixelRef.h ('k') | src/lazy/SkDiscardableMemoryPool.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698