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

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

Issue 1824983003: SkRecord: infer return type for visit() and mutate(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkRecord.cpp ('k') | src/core/SkRecordPattern.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"
(...skipping 22 matching lines...) Expand all
33 bbh->search(query, &ops); 33 bbh->search(query, &ops);
34 34
35 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); 35 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount);
36 for (int i = 0; i < ops.count(); i++) { 36 for (int i = 0; i < ops.count(); i++) {
37 if (callback && callback->abort()) { 37 if (callback && callback->abort()) {
38 return; 38 return;
39 } 39 }
40 // This visit call uses the SkRecords::Draw::operator() to call 40 // This visit call uses the SkRecords::Draw::operator() to call
41 // methods on the |canvas|, wrapped by methods defined with the 41 // methods on the |canvas|, wrapped by methods defined with the
42 // DRAW() macro. 42 // DRAW() macro.
43 record.visit<void>(ops[i], draw); 43 record.visit(ops[i], draw);
44 } 44 }
45 } else { 45 } else {
46 // Draw all ops. 46 // Draw all ops.
47 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount); 47 SkRecords::Draw draw(canvas, drawablePicts, drawables, drawableCount);
48 for (int i = 0; i < record.count(); i++) { 48 for (int i = 0; i < record.count(); i++) {
49 if (callback && callback->abort()) { 49 if (callback && callback->abort()) {
50 return; 50 return;
51 } 51 }
52 // This visit call uses the SkRecords::Draw::operator() to call 52 // This visit call uses the SkRecords::Draw::operator() to call
53 // methods on the |canvas|, wrapped by methods defined with the 53 // methods on the |canvas|, wrapped by methods defined with the
54 // DRAW() macro. 54 // DRAW() macro.
55 record.visit<void>(i, draw); 55 record.visit(i, draw);
56 } 56 }
57 } 57 }
58 } 58 }
59 59
60 void SkRecordPartialDraw(const SkRecord& record, SkCanvas* canvas, 60 void SkRecordPartialDraw(const SkRecord& record, SkCanvas* canvas,
61 SkPicture const* const drawablePicts[], int drawableCou nt, 61 SkPicture const* const drawablePicts[], int drawableCou nt,
62 int start, int stop, 62 int start, int stop,
63 const SkMatrix& initialCTM) { 63 const SkMatrix& initialCTM) {
64 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); 64 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/);
65 65
66 stop = SkTMin(stop, record.count()); 66 stop = SkTMin(stop, record.count());
67 SkRecords::Draw draw(canvas, drawablePicts, nullptr, drawableCount, &initial CTM); 67 SkRecords::Draw draw(canvas, drawablePicts, nullptr, drawableCount, &initial CTM);
68 for (int i = start; i < stop; i++) { 68 for (int i = start; i < stop; i++) {
69 record.visit<void>(i, draw); 69 record.visit(i, draw);
70 } 70 }
71 } 71 }
72 72
73 namespace SkRecords { 73 namespace SkRecords {
74 74
75 // NoOps draw nothing. 75 // NoOps draw nothing.
76 template <> void Draw::draw(const NoOp&) {} 76 template <> void Draw::draw(const NoOp&) {}
77 77
78 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; } 78 #define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
79 DRAW(Restore, restore()); 79 DRAW(Restore, restore());
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 return this->adjustAndMap(dst, &op.paint); 514 return this->adjustAndMap(dst, &op.paint);
515 } 515 }
516 516
517 Bounds bounds(const DrawDrawable& op) const { 517 Bounds bounds(const DrawDrawable& op) const {
518 return this->adjustAndMap(op.worstCaseBounds, nullptr); 518 return this->adjustAndMap(op.worstCaseBounds, nullptr);
519 } 519 }
520 520
521 Bounds bounds(const DrawAnnotation& op) const { 521 Bounds bounds(const DrawAnnotation& op) const {
522 return this->adjustAndMap(op.rect, nullptr); 522 return this->adjustAndMap(op.rect, nullptr);
523 } 523 }
524 524
525 static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) { 525 static void AdjustTextForFontMetrics(SkRect* rect, const SkPaint& paint) {
526 #ifdef SK_DEBUG 526 #ifdef SK_DEBUG
527 SkRect correct = *rect; 527 SkRect correct = *rect;
528 #endif 528 #endif
529 // crbug.com/373785 ~~> xPad = 4x yPad 529 // crbug.com/373785 ~~> xPad = 4x yPad
530 // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x 530 // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x
531 const SkScalar yPad = 2.5f * paint.getTextSize(), 531 const SkScalar yPad = 2.5f * paint.getTextSize(),
532 xPad = 4.0f * yPad; 532 xPad = 4.0f * yPad;
533 rect->outset(xPad, yPad); 533 rect->outset(xPad, yPad);
534 #ifdef SK_DEBUG 534 #ifdef SK_DEBUG
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 790
791 SkRecords::FillBounds fFillBounds; 791 SkRecords::FillBounds fFillBounds;
792 }; 792 };
793 793
794 } // namespace SkRecords 794 } // namespace SkRecords
795 795
796 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkRect b ounds[]) { 796 void SkRecordFillBounds(const SkRect& cullRect, const SkRecord& record, SkRect b ounds[]) {
797 SkRecords::FillBounds visitor(cullRect, record, bounds); 797 SkRecords::FillBounds visitor(cullRect, record, bounds);
798 for (int curOp = 0; curOp < record.count(); curOp++) { 798 for (int curOp = 0; curOp < record.count(); curOp++) {
799 visitor.setCurrentOp(curOp); 799 visitor.setCurrentOp(curOp);
800 record.visit<void>(curOp, visitor); 800 record.visit(curOp, visitor);
801 } 801 }
802 visitor.cleanUp(); 802 visitor.cleanUp();
803 } 803 }
804 804
805 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, SkRec t bounds[], 805 void SkRecordComputeLayers(const SkRect& cullRect, const SkRecord& record, SkRec t bounds[],
806 const SkBigPicture::SnapshotArray* pictList, SkLayerI nfo* data) { 806 const SkBigPicture::SnapshotArray* pictList, SkLayerI nfo* data) {
807 SkRecords::CollectLayers visitor(cullRect, record, bounds, pictList, data); 807 SkRecords::CollectLayers visitor(cullRect, record, bounds, pictList, data);
808 for (int curOp = 0; curOp < record.count(); curOp++) { 808 for (int curOp = 0; curOp < record.count(); curOp++) {
809 visitor.setCurrentOp(curOp); 809 visitor.setCurrentOp(curOp);
810 record.visit<void>(curOp, visitor); 810 record.visit(curOp, visitor);
811 } 811 }
812 visitor.cleanUp(); 812 visitor.cleanUp();
813 } 813 }
814 814
OLDNEW
« no previous file with comments | « src/core/SkRecord.cpp ('k') | src/core/SkRecordPattern.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698