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

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

Issue 835813002: Clean up dead clear() code in SkRecord. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Delete the test. Created 5 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
« no previous file with comments | « no previous file | src/core/SkRecords.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 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 "SkLayerInfo.h" 8 #include "SkLayerInfo.h"
9 #include "SkRecordDraw.h" 9 #include "SkRecordDraw.h"
10 #include "SkPatchUtils.h" 10 #include "SkPatchUtils.h"
11 11
12 void SkRecordDraw(const SkRecord& record, 12 void SkRecordDraw(const SkRecord& record,
13 SkCanvas* canvas, 13 SkCanvas* canvas,
14 SkPicture const* const drawablePicts[], 14 SkPicture const* const drawablePicts[],
15 SkCanvasDrawable* const drawables[], 15 SkCanvasDrawable* const drawables[],
16 int drawableCount, 16 int drawableCount,
17 const SkBBoxHierarchy* bbh, 17 const SkBBoxHierarchy* bbh,
18 SkDrawPictureCallback* callback) { 18 SkDrawPictureCallback* callback) {
19 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); 19 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
20 20
21 if (bbh) { 21 if (bbh) {
22 // Draw only ops that affect pixels in the canvas's current clip. 22 // Draw only ops that affect pixels in the canvas's current clip.
23 // The SkRecord and BBH were recorded in identity space. This canvas 23 // The SkRecord and BBH were recorded in identity space. This canvas
24 // is not necessarily in that same space. getClipBounds() returns us 24 // is not necessarily in that same space. getClipBounds() returns us
25 // this canvas' clip bounds transformed back into identity space, which 25 // this canvas' clip bounds transformed back into identity space, which
26 // lets us query the BBH. 26 // lets us query the BBH.
27 SkRect query; 27 SkRect query = {0,0,0,0};
28 if (!canvas->getClipBounds(&query)) { 28 (void)canvas->getClipBounds(&query);
reed1 2015/01/05 14:45:30 not sure why the new form is clearer.
mtklein 2015/01/05 14:49:17 You're saying you prefer SkRect query; if (!ca
reed1 2015/01/05 16:26:08 danke
29 // We want to make sure our query rectangle is never totally empty.
30 // Clear ignores the clip, so it must draw even if the clip is logic ally empty.
31 query = SkRect::MakeWH(SK_ScalarNearlyZero, SK_ScalarNearlyZero);
32 }
33 29
34 SkTDArray<unsigned> ops; 30 SkTDArray<unsigned> ops;
35 bbh->search(query, &ops); 31 bbh->search(query, &ops);
36 32
37 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); 33 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount);
38 for (int i = 0; i < ops.count(); i++) { 34 for (int i = 0; i < ops.count(); i++) {
39 if (callback && callback->abortDrawing()) { 35 if (callback && callback->abortDrawing()) {
40 return; 36 return;
41 } 37 }
42 // This visit call uses the SkRecords::Draw::operator() to call 38 // This visit call uses the SkRecords::Draw::operator() to call
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 70
75 namespace SkRecords { 71 namespace SkRecords {
76 72
77 // NoOps draw nothing. 73 // NoOps draw nothing.
78 template <> void Draw::draw(const NoOp&) {} 74 template <> void Draw::draw(const NoOp&) {}
79 75
80 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } 76 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
81 DRAW(Restore, restore()); 77 DRAW(Restore, restore());
82 DRAW(Save, save()); 78 DRAW(Save, save());
83 DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags)); 79 DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
84 DRAW(Clear, clear(r.color));
85 DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix))); 80 DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));
86 81
87 DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa)); 82 DRAW(ClipPath, clipPath(r.path, r.opAA.op, r.opAA.aa));
88 DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa)); 83 DRAW(ClipRRect, clipRRect(r.rrect, r.opAA.op, r.opAA.aa));
89 DRAW(ClipRect, clipRect(r.rect, r.opAA.op, r.opAA.aa)); 84 DRAW(ClipRect, clipRect(r.rect, r.opAA.op, r.opAA.aa));
90 DRAW(ClipRegion, clipRegion(r.region, r.op)); 85 DRAW(ClipRegion, clipRegion(r.region, r.op));
91 86
92 DRAW(BeginCommentGroup, beginCommentGroup(r.description)); 87 DRAW(BeginCommentGroup, beginCommentGroup(r.description));
93 DRAW(AddComment, addComment(r.key, r.value)); 88 DRAW(AddComment, addComment(r.key, r.value));
94 DRAW(EndCommentGroup, endCommentGroup()); 89 DRAW(EndCommentGroup, endCommentGroup());
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // Adjust rect for all the paints from the SaveLayers we're inside. 206 // Adjust rect for all the paints from the SaveLayers we're inside.
212 if (!this->adjustForSaveLayerPaints(&rect)) { 207 if (!this->adjustForSaveLayerPaints(&rect)) {
213 // Same deal as above. 208 // Same deal as above.
214 return fCurrentClipBounds; 209 return fCurrentClipBounds;
215 } 210 }
216 211
217 // Map the rect back to identity space. 212 // Map the rect back to identity space.
218 fCTM->mapRect(&rect); 213 fCTM->mapRect(&rect);
219 214
220 // Nothing can draw outside the current clip. 215 // Nothing can draw outside the current clip.
221 // (Only bounded ops call into this method, so oddballs like Clear don't matter here.)
222 if (!rect.intersect(fCurrentClipBounds)) { 216 if (!rect.intersect(fCurrentClipBounds)) {
223 return Bounds::MakeEmpty(); 217 return Bounds::MakeEmpty();
224 } 218 }
225 219
226 return rect; 220 return rect;
227 } 221 }
228 222
229 private: 223 private:
230 struct SaveBounds { 224 struct SaveBounds {
231 int controlOps; // Number of control ops in this Save block, incl uding the Save. 225 int controlOps; // Number of control ops in this Save block, incl uding the Save.
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 void updateSaveBounds(const Bounds& bounds) { 375 void updateSaveBounds(const Bounds& bounds) {
382 // If we're in a Save block, expand its bounds to cover these bounds too . 376 // If we're in a Save block, expand its bounds to cover these bounds too .
383 if (!fSaveStack.isEmpty()) { 377 if (!fSaveStack.isEmpty()) {
384 fSaveStack.top().bounds.join(bounds); 378 fSaveStack.top().bounds.join(bounds);
385 } 379 }
386 } 380 }
387 381
388 // FIXME: this method could use better bounds 382 // FIXME: this method could use better bounds
389 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } 383 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; }
390 384
391 Bounds bounds(const Clear&) const { return fCullRect; } // Ignor es the clip.
392 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } 385 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; }
393 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp s don't draw. 386 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp s don't draw.
394 387
395 Bounds bounds(const DrawSprite& op) const { // Ignores the matrix. 388 Bounds bounds(const DrawSprite& op) const { // Ignores the matrix.
396 return Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.he ight()); 389 return Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.he ight());
397 } 390 }
398 391
399 Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } 392 Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); }
400 Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); } 393 Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); }
401 Bounds bounds(const DrawRRect& op) const { 394 Bounds bounds(const DrawRRect& op) const {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); 785 SkRecords::CollectLayers visitor(cullRect, record, pictList, data);
793 786
794 for (unsigned curOp = 0; curOp < record.count(); curOp++) { 787 for (unsigned curOp = 0; curOp < record.count(); curOp++) {
795 visitor.setCurrentOp(curOp); 788 visitor.setCurrentOp(curOp);
796 record.visit<void>(curOp, visitor); 789 record.visit<void>(curOp, visitor);
797 } 790 }
798 791
799 visitor.cleanUp(bbh); 792 visitor.cleanUp(bbh);
800 } 793 }
801 794
OLDNEW
« no previous file with comments | « no previous file | src/core/SkRecords.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698