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

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

Issue 2277053002: Add drawRegion() API to SkCanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Added shader to test Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImageFilter.h" 10 #include "SkImageFilter.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 static void make_threadsafe(SkPath* path, SkMatrix* matrix) { 47 static void make_threadsafe(SkPath* path, SkMatrix* matrix) {
48 if (path) { path->updateBoundsCache(); } 48 if (path) { path->updateBoundsCache(); }
49 if (matrix) { (void)matrix->getType(); } 49 if (matrix) { (void)matrix->getType(); }
50 } 50 }
51 51
52 namespace { 52 namespace {
53 #define TYPES(M) \ 53 #define TYPES(M) \
54 M(Save) M(Restore) M(SaveLayer) \ 54 M(Save) M(Restore) M(SaveLayer) \
55 M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \ 55 M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \
56 M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \ 56 M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \
57 M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawOval) M(DrawArc) M(DrawRRect) \ 57 M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawRegion) M(DrawOval) M(DrawArc) \
58 M(DrawDRRect) M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) \ 58 M(DrawRRect) M(DrawDRRect) M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) \
59 M(DrawShadowedPicture) \ 59 M(DrawShadowedPicture) \
60 M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice) \ 60 M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice) \
61 M(DrawText) M(DrawPosText) M(DrawPosTextH) \ 61 M(DrawText) M(DrawPosText) M(DrawPosTextH) \
62 M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob) \ 62 M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob) \
63 M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas) 63 M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas)
64 64
65 #define M(T) T, 65 #define M(T) T,
66 enum class Type : uint8_t { TYPES(M) }; 66 enum class Type : uint8_t { TYPES(M) };
67 #undef M 67 #undef M
68 68
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void draw(SkCanvas* c, const SkMatrix&) { c->drawPath(path, paint); } 182 void draw(SkCanvas* c, const SkMatrix&) { c->drawPath(path, paint); }
183 void makeThreadsafe() { make_threadsafe(&path, nullptr); } 183 void makeThreadsafe() { make_threadsafe(&path, nullptr); }
184 }; 184 };
185 struct DrawRect final : Op { 185 struct DrawRect final : Op {
186 static const auto kType = Type::DrawRect; 186 static const auto kType = Type::DrawRect;
187 DrawRect(const SkRect& rect, const SkPaint& paint) : rect(rect), paint(p aint) {} 187 DrawRect(const SkRect& rect, const SkPaint& paint) : rect(rect), paint(p aint) {}
188 SkRect rect; 188 SkRect rect;
189 SkPaint paint; 189 SkPaint paint;
190 void draw(SkCanvas* c, const SkMatrix&) { c->drawRect(rect, paint); } 190 void draw(SkCanvas* c, const SkMatrix&) { c->drawRect(rect, paint); }
191 }; 191 };
192 struct DrawRegion final : Op {
193 static const auto kType = Type::DrawRegion;
194 DrawRegion(const SkRegion& region, const SkPaint& paint) : region(region ), paint(paint) {}
195 SkRegion region;
196 SkPaint paint;
197 void draw(SkCanvas* c, const SkMatrix&) { c->drawRegion(region, paint); }
198 };
192 struct DrawOval final : Op { 199 struct DrawOval final : Op {
193 static const auto kType = Type::DrawOval; 200 static const auto kType = Type::DrawOval;
194 DrawOval(const SkRect& oval, const SkPaint& paint) : oval(oval), paint(p aint) {} 201 DrawOval(const SkRect& oval, const SkPaint& paint) : oval(oval), paint(p aint) {}
195 SkRect oval; 202 SkRect oval;
196 SkPaint paint; 203 SkPaint paint;
197 void draw(SkCanvas* c, const SkMatrix&) { c->drawOval(oval, paint); } 204 void draw(SkCanvas* c, const SkMatrix&) { c->drawOval(oval, paint); }
198 }; 205 };
199 struct DrawArc final : Op { 206 struct DrawArc final : Op {
200 static const auto kType = Type::DrawArc; 207 static const auto kType = Type::DrawArc;
201 DrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bo ol useCenter, 208 DrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bo ol useCenter,
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 589
583 void SkLiteDL::drawPaint(const SkPaint& paint) { 590 void SkLiteDL::drawPaint(const SkPaint& paint) {
584 this->push<DrawPaint>(0, paint); 591 this->push<DrawPaint>(0, paint);
585 } 592 }
586 void SkLiteDL::drawPath(const SkPath& path, const SkPaint& paint) { 593 void SkLiteDL::drawPath(const SkPath& path, const SkPaint& paint) {
587 this->push<DrawPath>(0, path, paint); 594 this->push<DrawPath>(0, path, paint);
588 } 595 }
589 void SkLiteDL::drawRect(const SkRect& rect, const SkPaint& paint) { 596 void SkLiteDL::drawRect(const SkRect& rect, const SkPaint& paint) {
590 this->push<DrawRect>(0, rect, paint); 597 this->push<DrawRect>(0, rect, paint);
591 } 598 }
599 void SkLiteDL::drawRegion(const SkRegion& region, const SkPaint& paint) {
600 this->push<DrawRegion>(0, region, paint);
601 }
592 void SkLiteDL::drawOval(const SkRect& oval, const SkPaint& paint) { 602 void SkLiteDL::drawOval(const SkRect& oval, const SkPaint& paint) {
593 this->push<DrawOval>(0, oval, paint); 603 this->push<DrawOval>(0, oval, paint);
594 } 604 }
595 void SkLiteDL::drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAn gle, bool useCenter, 605 void SkLiteDL::drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAn gle, bool useCenter,
596 const SkPaint& paint) { 606 const SkPaint& paint) {
597 this->push<DrawArc>(0, oval, startAngle, sweepAngle, useCenter, paint); 607 this->push<DrawArc>(0, oval, startAngle, sweepAngle, useCenter, paint);
598 } 608 }
599 void SkLiteDL::drawRRect(const SkRRect& rrect, const SkPaint& paint) { 609 void SkLiteDL::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
600 this->push<DrawRRect>(0, rrect, paint); 610 this->push<DrawRRect>(0, rrect, paint);
601 } 611 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 } 782 }
773 783
774 void SkLiteDL::reset(SkRect bounds) { 784 void SkLiteDL::reset(SkRect bounds) {
775 SkASSERT(this->unique()); 785 SkASSERT(this->unique());
776 this->map(dtor_fns); 786 this->map(dtor_fns);
777 787
778 // Leave fBytes and fReserved alone. 788 // Leave fBytes and fReserved alone.
779 fUsed = 0; 789 fUsed = 0;
780 fBounds = bounds; 790 fBounds = bounds;
781 } 791 }
OLDNEW
« include/core/SkCanvas.h ('K') | « src/core/SkLiteDL.h ('k') | src/core/SkLiteRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698