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

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

Issue 527423002: SkRecordPartialDraw with less code duplication (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: test 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/SkRecordDraw.h ('k') | tests/RecordDrawTest.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
(...skipping 17 matching lines...) Expand all
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 (NULL != 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 for (SkRecords::Draw draw(canvas); draw.index() < record.count(); draw.n ext()) { 38 SkRecords::Draw draw(canvas);
39 for (unsigned i = 0; i < record.count(); i++) {
39 if (NULL != callback && callback->abortDrawing()) { 40 if (NULL != callback && callback->abortDrawing()) {
40 return; 41 return;
41 } 42 }
42 record.visit<void>(draw.index(), draw); 43 record.visit<void>(i, draw);
43 } 44 }
44 } 45 }
45 } 46 }
46 47
48 void SkRecordPartialDraw(const SkRecord& record,
49 SkCanvas* canvas,
50 const SkRect& clearRect,
51 unsigned start, unsigned stop) {
52 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
53
54 stop = SkTMin(stop, record.count());
55 SkRecords::PartialDraw draw(canvas, clearRect);
56 for (unsigned i = start; i < stop; i++) {
57 record.visit<void>(i, draw);
58 }
59 }
60
47 namespace SkRecords { 61 namespace SkRecords {
48 62
49 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip le threads. 63 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip le threads.
50 static SkBitmap shallow_copy(const SkBitmap& bitmap) { 64 static SkBitmap shallow_copy(const SkBitmap& bitmap) {
51 return bitmap; 65 return bitmap;
52 } 66 }
53 67
54 // NoOps draw nothing. 68 // NoOps draw nothing.
55 template <> void Draw::draw(const NoOp&) {} 69 template <> void Draw::draw(const NoOp&) {}
56 70
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 // Used to track the bounds of Save/Restore blocks and the control ops insid e them. 470 // Used to track the bounds of Save/Restore blocks and the control ops insid e them.
457 SkTDArray<SaveBounds> fSaveStack; 471 SkTDArray<SaveBounds> fSaveStack;
458 SkTDArray<unsigned> fControlIndices; 472 SkTDArray<unsigned> fControlIndices;
459 }; 473 };
460 474
461 } // namespace SkRecords 475 } // namespace SkRecords
462 476
463 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) { 477 void SkRecordFillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) {
464 SkRecords::FillBounds(record, bbh); 478 SkRecords::FillBounds(record, bbh);
465 } 479 }
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.h ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698