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

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

Issue 2264433002: Revert of Fast path translate() in SkCanvas and SkLiteDL. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/SkLiteDL.h ('k') | src/core/SkLiteRecorder.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 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
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(Translate) M(TranslateZ) \ 55 M(Concat) M(SetMatrix) 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
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 };
126 struct TranslateZ final : Op { 118 struct TranslateZ final : Op {
127 static const auto kType = Type::TranslateZ; 119 static const auto kType = Type::TranslateZ;
128 TranslateZ(SkScalar dz) : dz(dz) {} 120 TranslateZ(SkScalar dz) : dz(dz) {}
129 SkScalar dz; 121 SkScalar dz;
130 void draw(SkCanvas* c, const SkMatrix&) { 122 void draw(SkCanvas* c, const SkMatrix&) {
131 #ifdef SK_EXPERIMENTAL_SHADOWING 123 #ifdef SK_EXPERIMENTAL_SHADOWING
132 c->translateZ(dz); 124 c->translateZ(dz);
133 #endif 125 #endif
134 } 126 }
135 }; 127 };
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 532 }
541 } 533 }
542 534
543 void SkLiteDL:: save() { this->push <Save>(0); } 535 void SkLiteDL:: save() { this->push <Save>(0); }
544 void SkLiteDL::restore() { this->push<Restore>(0); } 536 void SkLiteDL::restore() { this->push<Restore>(0); }
545 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint, 537 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint,
546 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) { 538 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) {
547 this->push<SaveLayer>(0, bounds, paint, backdrop, flags); 539 this->push<SaveLayer>(0, bounds, paint, backdrop, flags);
548 } 540 }
549 541
550 void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, ma trix); } 542 void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, matr ix); }
551 void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, ma trix); } 543 void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, matr ix); }
552 void SkLiteDL::translate(SkScalar dx, SkScalar dy) { this->push<Translate>(0, dx , dy); }
553 void SkLiteDL::translateZ(SkScalar dz) { this->push<TranslateZ>(0, dz); } 544 void SkLiteDL::translateZ(SkScalar dz) { this->push<TranslateZ>(0, dz); }
554 545
555 void SkLiteDL::clipPath(const SkPath& path, SkRegion::Op op, bool aa) { 546 void SkLiteDL::clipPath(const SkPath& path, SkRegion::Op op, bool aa) {
556 this->push<ClipPath>(0, path, op, aa); 547 this->push<ClipPath>(0, path, op, aa);
557 } 548 }
558 void SkLiteDL::clipRect(const SkRect& rect, SkRegion::Op op, bool aa) { 549 void SkLiteDL::clipRect(const SkRect& rect, SkRegion::Op op, bool aa) {
559 this->push<ClipRect>(0, rect, op, aa); 550 this->push<ClipRect>(0, rect, op, aa);
560 } 551 }
561 void SkLiteDL::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) { 552 void SkLiteDL::clipRRect(const SkRRect& rrect, SkRegion::Op op, bool aa) {
562 this->push<ClipRRect>(0, rrect, op, aa); 553 this->push<ClipRRect>(0, rrect, op, aa);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 } 744 }
754 745
755 void SkLiteDL::reset(SkRect bounds) { 746 void SkLiteDL::reset(SkRect bounds) {
756 SkASSERT(this->unique()); 747 SkASSERT(this->unique());
757 this->map(dtor_fns); 748 this->map(dtor_fns);
758 749
759 // Leave fBytes and fReserved alone. 750 // Leave fBytes and fReserved alone.
760 fUsed = 0; 751 fUsed = 0;
761 fBounds = bounds; 752 fBounds = bounds;
762 } 753 }
OLDNEW
« no previous file with comments | « src/core/SkLiteDL.h ('k') | src/core/SkLiteRecorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698