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

Side by Side Diff: src/core/SkPictureRecorder.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 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/core/SkPictureRecord.cpp ('k') | src/core/SkPictureShader.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 2014 Google Inc. 2 * Copyright 2014 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 "SkBBoxHierarchyRecord.h" 8 #include "SkBBoxHierarchyRecord.h"
9 #include "SkPictureRecord.h" 9 #include "SkPictureRecord.h"
10 #include "SkPictureRecorder.h" 10 #include "SkPictureRecorder.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 SkCanvas* SkPictureRecorder::DEPRECATED_beginRecording(SkScalar width, SkScalar height, 30 SkCanvas* SkPictureRecorder::DEPRECATED_beginRecording(SkScalar width, SkScalar height,
31 SkBBHFactory* bbhFactory /* = NULL */, 31 SkBBHFactory* bbhFactory /* = NULL */,
32 uint32_t recordFlags /* = 0 */) { 32 uint32_t recordFlags /* = 0 */) {
33 fCullWidth = width; 33 fCullWidth = width;
34 fCullHeight = height; 34 fCullHeight = height;
35 35
36 const SkISize size = SkISize::Make(width, height); 36 const SkISize size = SkISize::Make(width, height);
37 37
38 if (NULL != bbhFactory) { 38 if (bbhFactory) {
39 // We don't need to hold a ref on the BBH ourselves, but might as well f or 39 // We don't need to hold a ref on the BBH ourselves, but might as well f or
40 // consistency with EXPERIMENTAL_beginRecording(), which does need to. 40 // consistency with EXPERIMENTAL_beginRecording(), which does need to.
41 fBBH.reset((*bbhFactory)(width, height)); 41 fBBH.reset((*bbhFactory)(width, height));
42 SkASSERT(NULL != fBBH.get()); 42 SkASSERT(fBBH.get());
43 fPictureRecord.reset(SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlag s, fBBH.get()))); 43 fPictureRecord.reset(SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlag s, fBBH.get())));
44 } else { 44 } else {
45 fPictureRecord.reset(SkNEW_ARGS(SkPictureRecord, (size, recordFlags))); 45 fPictureRecord.reset(SkNEW_ARGS(SkPictureRecord, (size, recordFlags)));
46 } 46 }
47 47
48 fPictureRecord->beginRecording(); 48 fPictureRecord->beginRecording();
49 return this->getRecordingCanvas(); 49 return this->getRecordingCanvas();
50 } 50 }
51 51
52 SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(SkScalar width, SkScala r height, 52 SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(SkScalar width, SkScala r height,
53 SkBBHFactory* bbhFactor y /* = NULL */) { 53 SkBBHFactory* bbhFactor y /* = NULL */) {
54 fCullWidth = width; 54 fCullWidth = width;
55 fCullHeight = height; 55 fCullHeight = height;
56 56
57 if (NULL != bbhFactory) { 57 if (bbhFactory) {
58 fBBH.reset((*bbhFactory)(width, height)); 58 fBBH.reset((*bbhFactory)(width, height));
59 SkASSERT(NULL != fBBH.get()); 59 SkASSERT(fBBH.get());
60 } 60 }
61 61
62 fRecord.reset(SkNEW(SkRecord)); 62 fRecord.reset(SkNEW(SkRecord));
63 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), width, height))); 63 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), width, height)));
64 return this->getRecordingCanvas(); 64 return this->getRecordingCanvas();
65 } 65 }
66 66
67 SkCanvas* SkPictureRecorder::getRecordingCanvas() { 67 SkCanvas* SkPictureRecorder::getRecordingCanvas() {
68 if (NULL != fRecorder.get()) { 68 if (fRecorder.get()) {
69 return fRecorder.get(); 69 return fRecorder.get();
70 } 70 }
71 return fPictureRecord.get(); 71 return fPictureRecord.get();
72 } 72 }
73 73
74 SkPicture* SkPictureRecorder::endRecording() { 74 SkPicture* SkPictureRecorder::endRecording() {
75 SkPicture* picture = NULL; 75 SkPicture* picture = NULL;
76 76
77 if (NULL != fRecord.get()) { 77 if (fRecord.get()) {
78 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, 78 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight,
79 fRecord.detach(), fBBH.get())); 79 fRecord.detach(), fBBH.get()));
80 } 80 }
81 81
82 if (NULL != fPictureRecord.get()) { 82 if (fPictureRecord.get()) {
83 fPictureRecord->endRecording(); 83 fPictureRecord->endRecording();
84 const bool deepCopyOps = false; 84 const bool deepCopyOps = false;
85 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, 85 picture = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight,
86 *fPictureRecord.get(), deepCopyOps)); 86 *fPictureRecord.get(), deepCopyOps));
87 } 87 }
88 88
89 return picture; 89 return picture;
90 } 90 }
91 91
92 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) { 92 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
93 if (NULL != fPictureRecord.get()) { 93 if (fPictureRecord.get()) {
94 fPictureRecord->internalOnly_EnableOpts(enableOpts); 94 fPictureRecord->internalOnly_EnableOpts(enableOpts);
95 } 95 }
96 } 96 }
97 97
98 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 98 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
99 if (NULL == canvas) { 99 if (NULL == canvas) {
100 return; 100 return;
101 } 101 }
102 102
103 if (NULL != fRecord.get()) { 103 if (fRecord.get()) {
104 SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/); 104 SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/);
105 } 105 }
106 106
107 if (NULL != fPictureRecord.get()) { 107 if (fPictureRecord.get()) {
108 const bool deepCopyOps = true; 108 const bool deepCopyOps = true;
109 SkPicture picture(fCullWidth, fCullHeight, 109 SkPicture picture(fCullWidth, fCullHeight,
110 *fPictureRecord.get(), deepCopyOps); 110 *fPictureRecord.get(), deepCopyOps);
111 picture.playback(canvas); 111 picture.playback(canvas);
112 } 112 }
113 } 113 }
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/core/SkPictureShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698