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

Side by Side Diff: src/core/SkRecordDraw.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/SkRTree.cpp ('k') | src/core/SkResourceCache.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 "SkRecordDraw.h" 8 #include "SkRecordDraw.h"
9 #include "SkPatchUtils.h" 9 #include "SkPatchUtils.h"
10 10
11 void SkRecordDraw(const SkRecord& record, 11 void SkRecordDraw(const SkRecord& record,
12 SkCanvas* canvas, 12 SkCanvas* canvas,
13 const SkBBoxHierarchy* bbh, 13 const SkBBoxHierarchy* bbh,
14 SkDrawPictureCallback* callback) { 14 SkDrawPictureCallback* callback) {
15 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); 15 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
16 16
17 if (NULL != bbh) { 17 if (bbh) {
18 // Draw only ops that affect pixels in the canvas's current clip. 18 // Draw only ops that affect pixels in the canvas's current clip.
19 // The SkRecord and BBH were recorded in identity space. This canvas 19 // The SkRecord and BBH were recorded in identity space. This canvas
20 // is not necessarily in that same space. getClipBounds() returns us 20 // is not necessarily in that same space. getClipBounds() returns us
21 // this canvas' clip bounds transformed back into identity space, which 21 // this canvas' clip bounds transformed back into identity space, which
22 // lets us query the BBH. 22 // lets us query the BBH.
23 SkRect query = { 0, 0, 0, 0 }; 23 SkRect query = { 0, 0, 0, 0 };
24 (void)canvas->getClipBounds(&query); 24 (void)canvas->getClipBounds(&query);
25 25
26 SkTDArray<void*> ops; 26 SkTDArray<void*> ops;
27 bbh->search(query, &ops); 27 bbh->search(query, &ops);
28 28
29 SkRecords::Draw draw(canvas); 29 SkRecords::Draw draw(canvas);
30 for (int i = 0; i < ops.count(); i++) { 30 for (int i = 0; i < ops.count(); i++) {
31 if (NULL != callback && callback->abortDrawing()) { 31 if (callback && callback->abortDrawing()) {
32 return; 32 return;
33 } 33 }
34 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo w. 34 record.visit<void>((uintptr_t)ops[i], draw); // See FillBounds belo w.
35 } 35 }
36 } else { 36 } else {
37 // Draw all ops. 37 // Draw all ops.
38 SkRecords::Draw draw(canvas); 38 SkRecords::Draw draw(canvas);
39 for (unsigned i = 0; i < record.count(); i++) { 39 for (unsigned i = 0; i < record.count(); i++) {
40 if (NULL != callback && callback->abortDrawing()) { 40 if (callback && callback->abortDrawing()) {
41 return; 41 return;
42 } 42 }
43 record.visit<void>(i, draw); 43 record.visit<void>(i, draw);
44 } 44 }
45 } 45 }
46 } 46 }
47 47
48 void SkRecordPartialDraw(const SkRecord& record, 48 void SkRecordPartialDraw(const SkRecord& record,
49 SkCanvas* canvas, 49 SkCanvas* canvas,
50 const SkRect& clearRect, 50 const SkRect& clearRect,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 while (!fSaveStack.isEmpty()) { 147 while (!fSaveStack.isEmpty()) {
148 this->popSaveBlock(); 148 this->popSaveBlock();
149 } 149 }
150 150
151 // Any control ops not part of any Save/Restore block draw everywhere. 151 // Any control ops not part of any Save/Restore block draw everywhere.
152 while (!fControlIndices.isEmpty()) { 152 while (!fControlIndices.isEmpty()) {
153 this->popControl(largest); 153 this->popControl(largest);
154 } 154 }
155 155
156 // Finally feed all stored bounds into the BBH. They'll be returned in this order. 156 // Finally feed all stored bounds into the BBH. They'll be returned in this order.
157 SkASSERT(NULL != bbh); 157 SkASSERT(bbh);
158 for (uintptr_t i = 0; i < record.count(); i++) { 158 for (uintptr_t i = 0; i < record.count(); i++) {
159 if (!fBounds[i].isEmpty()) { 159 if (!fBounds[i].isEmpty()) {
160 bbh->insert((void*)i, fBounds[i], true/*ok to defer*/); 160 bbh->insert((void*)i, fBounds[i], true/*ok to defer*/);
161 } 161 }
162 } 162 }
163 bbh->flushDeferredInserts(); 163 bbh->flushDeferredInserts();
164 } 164 }
165 165
166 template <typename T> void operator()(const T& op) { 166 template <typename T> void operator()(const T& op) {
167 this->updateCTM(op); 167 this->updateCTM(op);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. 472 // Used to track the bounds of Save/Restore blocks and the control ops insid e them.
473 SkTDArray<SaveBounds> fSaveStack; 473 SkTDArray<SaveBounds> fSaveStack;
474 SkTDArray<unsigned> fControlIndices; 474 SkTDArray<unsigned> fControlIndices;
475 }; 475 };
476 476
477 } // namespace SkRecords 477 } // namespace SkRecords
478 478
479 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { 479 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) {
480 SkRecords::FillBounds(record, bbh); 480 SkRecords::FillBounds(record, bbh);
481 } 481 }
OLDNEW
« no previous file with comments | « src/core/SkRTree.cpp ('k') | src/core/SkResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698