OLD | NEW |
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Pre-cache lazy non-threadsafe fields on SkPath and/or SkMatrix. | 46 // Pre-cache lazy non-threadsafe fields on SkPath and/or SkMatrix. |
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(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(DrawRRect) M(DrawDRRect)
\ | 57 M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawOval) M(DrawRRect) M(DrawDRRect)
\ |
58 M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) M(DrawShadowedPicture)
\ | 58 M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) M(DrawShadowedPicture)
\ |
59 M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice)
\ | 59 M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice)
\ |
60 M(DrawText) M(DrawPosText) M(DrawPosTextH)
\ | 60 M(DrawText) M(DrawPosText) M(DrawPosTextH)
\ |
61 M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob)
\ | 61 M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob)
\ |
62 M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas) | 62 M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas) |
63 | 63 |
64 #define M(T) T, | 64 #define M(T) T, |
65 enum class Type : uint8_t { TYPES(M) }; | 65 enum class Type : uint8_t { TYPES(M) }; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 }; | 108 }; |
109 struct SetMatrix final : Op { | 109 struct SetMatrix final : Op { |
110 static const auto kType = Type::SetMatrix; | 110 static const auto kType = Type::SetMatrix; |
111 SetMatrix(const SkMatrix& matrix) : matrix(matrix) {} | 111 SetMatrix(const SkMatrix& matrix) : matrix(matrix) {} |
112 SkMatrix matrix; | 112 SkMatrix matrix; |
113 void draw(SkCanvas* c, const SkMatrix& original) { | 113 void draw(SkCanvas* c, const SkMatrix& original) { |
114 c->setMatrix(SkMatrix::Concat(original, matrix)); | 114 c->setMatrix(SkMatrix::Concat(original, matrix)); |
115 } | 115 } |
116 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } | 116 void makeThreadsafe() { make_threadsafe(nullptr, &matrix); } |
117 }; | 117 }; |
| 118 struct Translate final : Op { |
| 119 static const auto kType = Type::Translate; |
| 120 Translate(SkScalar dx, SkScalar dy) : dx(dx), dy(dy) {} |
| 121 SkScalar dx,dy; |
| 122 void draw(SkCanvas* c, const SkMatrix&) { |
| 123 c->translate(dx, dy); |
| 124 } |
| 125 }; |
118 struct TranslateZ final : Op { | 126 struct TranslateZ final : Op { |
119 static const auto kType = Type::TranslateZ; | 127 static const auto kType = Type::TranslateZ; |
120 TranslateZ(SkScalar dz) : dz(dz) {} | 128 TranslateZ(SkScalar dz) : dz(dz) {} |
121 SkScalar dz; | 129 SkScalar dz; |
122 void draw(SkCanvas* c, const SkMatrix&) { | 130 void draw(SkCanvas* c, const SkMatrix&) { |
123 #ifdef SK_EXPERIMENTAL_SHADOWING | 131 #ifdef SK_EXPERIMENTAL_SHADOWING |
124 c->translateZ(dz); | 132 c->translateZ(dz); |
125 #endif | 133 #endif |
126 } | 134 } |
127 }; | 135 }; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 } | 540 } |
533 } | 541 } |
534 | 542 |
535 void SkLiteDL:: save() { this->push <Save>(0); } | 543 void SkLiteDL:: save() { this->push <Save>(0); } |
536 void SkLiteDL::restore() { this->push<Restore>(0); } | 544 void SkLiteDL::restore() { this->push<Restore>(0); } |
537 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint, | 545 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint, |
538 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags
flags) { | 546 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags
flags) { |
539 this->push<SaveLayer>(0, bounds, paint, backdrop, flags); | 547 this->push<SaveLayer>(0, bounds, paint, backdrop, flags); |
540 } | 548 } |
541 | 549 |
542 void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, matr
ix); } | 550 void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, ma
trix); } |
543 void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, matr
ix); } | 551 void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, ma
trix); } |
| 552 void SkLiteDL::translate(SkScalar dx, SkScalar dy) { this->push<Translate>(0, dx
, dy); } |
544 void SkLiteDL::translateZ(SkScalar dz) { this->push<TranslateZ>(0, dz); } | 553 void SkLiteDL::translateZ(SkScalar dz) { this->push<TranslateZ>(0, dz); } |
545 | 554 |
546 void SkLiteDL::clipPath(const SkPath& path, SkRegion::Op op, bool aa) { | 555 void SkLiteDL::clipPath(const SkPath& path, SkRegion::Op op, bool aa) { |
547 this->push<ClipPath>(0, path, op, aa); | 556 this->push<ClipPath>(0, path, op, aa); |
548 } | 557 } |
549 void SkLiteDL::clipRect(const SkRect& rect, SkRegion::Op op, bool aa) { | 558 void SkLiteDL::clipRect(const SkRect& rect, SkRegion::Op op, bool aa) { |
550 this->push<ClipRect>(0, rect, op, aa); | 559 this->push<ClipRect>(0, rect, op, aa); |
551 } | 560 } |
552 void SkLiteDL::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) { | 561 void SkLiteDL::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) { |
553 this->push<ClipRRect>(0, rrect, op, aa); | 562 this->push<ClipRRect>(0, rrect, op, aa); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 753 } |
745 | 754 |
746 void SkLiteDL::reset(SkRect bounds) { | 755 void SkLiteDL::reset(SkRect bounds) { |
747 SkASSERT(this->unique()); | 756 SkASSERT(this->unique()); |
748 this->map(dtor_fns); | 757 this->map(dtor_fns); |
749 | 758 |
750 // Leave fBytes and fReserved alone. | 759 // Leave fBytes and fReserved alone. |
751 fUsed = 0; | 760 fUsed = 0; |
752 fBounds = bounds; | 761 fBounds = bounds; |
753 } | 762 } |
OLD | NEW |