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

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

Issue 2303033002: record drawfilters (Closed)
Patch Set: remove obsolete comment 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
« 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 "SkDrawFilter.h"
10 #include "SkImageFilter.h" 11 #include "SkImageFilter.h"
11 #include "SkLiteDL.h" 12 #include "SkLiteDL.h"
12 #include "SkMath.h" 13 #include "SkMath.h"
13 #include "SkPicture.h" 14 #include "SkPicture.h"
14 #include "SkRSXform.h" 15 #include "SkRSXform.h"
15 #include "SkTextBlob.h" 16 #include "SkTextBlob.h"
16 17
17 #ifndef SKLITEDL_PAGE 18 #ifndef SKLITEDL_PAGE
18 #define SKLITEDL_PAGE 4096 19 #define SKLITEDL_PAGE 4096
19 #endif 20 #endif
(...skipping 25 matching lines...) Expand all
45 static void make_threadsafe(SkPath* path, SkMatrix* matrix) { 46 static void make_threadsafe(SkPath* path, SkMatrix* matrix) {
46 if (path) { 47 if (path) {
47 path->updateBoundsCache(); 48 path->updateBoundsCache();
48 (void)path->getConvexity(); 49 (void)path->getConvexity();
49 } 50 }
50 if (matrix) { (void)matrix->getType(); } 51 if (matrix) { (void)matrix->getType(); }
51 } 52 }
52 53
53 namespace { 54 namespace {
54 #define TYPES(M) \ 55 #define TYPES(M) \
55 M(Save) M(Restore) M(SaveLayer) \ 56 M(SetDrawFilter) M(Save) M(Restore) M(SaveLayer) \
56 M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \ 57 M(Concat) M(SetMatrix) M(Translate) M(TranslateZ) \
57 M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \ 58 M(ClipPath) M(ClipRect) M(ClipRRect) M(ClipRegion) \
58 M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawRegion) M(DrawOval) M(DrawArc) \ 59 M(DrawPaint) M(DrawPath) M(DrawRect) M(DrawRegion) M(DrawOval) M(DrawArc) \
59 M(DrawRRect) M(DrawDRRect) M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) \ 60 M(DrawRRect) M(DrawDRRect) M(DrawAnnotation) M(DrawDrawable) M(DrawPicture) \
60 M(DrawShadowedPicture) \ 61 M(DrawShadowedPicture) \
61 M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice) \ 62 M(DrawImage) M(DrawImageNine) M(DrawImageRect) M(DrawImageLattice) \
62 M(DrawText) M(DrawPosText) M(DrawPosTextH) \ 63 M(DrawText) M(DrawPosText) M(DrawPosTextH) \
63 M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob) \ 64 M(DrawTextOnPath) M(DrawTextRSXform) M(DrawTextBlob) \
64 M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas) 65 M(DrawPatch) M(DrawPoints) M(DrawVertices) M(DrawAtlas)
65 66
66 #define M(T) T, 67 #define M(T) T,
67 enum class Type : uint8_t { TYPES(M) }; 68 enum class Type : uint8_t { TYPES(M) };
68 #undef M 69 #undef M
69 70
70 struct Op { 71 struct Op {
71 void makeThreadsafe() {} 72 void makeThreadsafe() {}
72 73
73 uint32_t type : 8; 74 uint32_t type : 8;
74 uint32_t skip : 24; 75 uint32_t skip : 24;
75 }; 76 };
76 static_assert(sizeof(Op) == 4, ""); 77 static_assert(sizeof(Op) == 4, "");
77 78
79 struct SetDrawFilter final : Op {
80 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER
81 static const auto kType = Type::SetDrawFilter;
82 SetDrawFilter(SkDrawFilter* df) : drawFilter(sk_ref_sp(df)) {}
83 sk_sp<SkDrawFilter> drawFilter;
84 #endif
85 void draw(SkCanvas* c, const SkMatrix&) {
86 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER
87 c->setDrawFilter(drawFilter.get());
88 #endif
89 }
90 };
91
78 struct Save final : Op { 92 struct Save final : Op {
79 static const auto kType = Type::Save; 93 static const auto kType = Type::Save;
80 void draw(SkCanvas* c, const SkMatrix&) { c->save(); } 94 void draw(SkCanvas* c, const SkMatrix&) { c->save(); }
81 }; 95 };
82 struct Restore final : Op { 96 struct Restore final : Op {
83 static const auto kType = Type::Restore; 97 static const auto kType = Type::Restore;
84 void draw(SkCanvas* c, const SkMatrix&) { c->restore(); } 98 void draw(SkCanvas* c, const SkMatrix&) { c->restore(); }
85 }; 99 };
86 struct SaveLayer final : Op { 100 struct SaveLayer final : Op {
87 static const auto kType = Type::SaveLayer; 101 static const auto kType = Type::SaveLayer;
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 auto op = (Op*)ptr; 573 auto op = (Op*)ptr;
560 auto type = op->type; 574 auto type = op->type;
561 auto skip = op->skip; 575 auto skip = op->skip;
562 if (auto fn = fns[type]) { // We replace no-op functions with nullptrs 576 if (auto fn = fns[type]) { // We replace no-op functions with nullptrs
563 fn(op, args...); // to avoid the overhead of a pointless call . 577 fn(op, args...); // to avoid the overhead of a pointless call .
564 } 578 }
565 ptr += skip; 579 ptr += skip;
566 } 580 }
567 } 581 }
568 582
583 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER
584 void SkLiteDL::setDrawFilter(SkDrawFilter* df) {
585 this->push<SetDrawFilter>(0, df);
586 }
587 #endif
588
569 void SkLiteDL:: save() { this->push <Save>(0); } 589 void SkLiteDL:: save() { this->push <Save>(0); }
570 void SkLiteDL::restore() { this->push<Restore>(0); } 590 void SkLiteDL::restore() { this->push<Restore>(0); }
571 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint, 591 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint,
572 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) { 592 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) {
573 this->push<SaveLayer>(0, bounds, paint, backdrop, flags); 593 this->push<SaveLayer>(0, bounds, paint, backdrop, flags);
574 } 594 }
575 595
576 void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, ma trix); } 596 void SkLiteDL:: concat(const SkMatrix& matrix) { this->push <Concat>(0, ma trix); }
577 void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, ma trix); } 597 void SkLiteDL::setMatrix(const SkMatrix& matrix) { this->push<SetMatrix>(0, ma trix); }
578 void SkLiteDL::translate(SkScalar dx, SkScalar dy) { this->push<Translate>(0, dx , dy); } 598 void SkLiteDL::translate(SkScalar dx, SkScalar dy) { this->push<Translate>(0, dx , dy); }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 } 806 }
787 807
788 void SkLiteDL::reset(SkRect bounds) { 808 void SkLiteDL::reset(SkRect bounds) {
789 SkASSERT(this->unique()); 809 SkASSERT(this->unique());
790 this->map(dtor_fns); 810 this->map(dtor_fns);
791 811
792 // Leave fBytes and fReserved alone. 812 // Leave fBytes and fReserved alone.
793 fUsed = 0; 813 fUsed = 0;
794 fBounds = bounds; 814 fBounds = bounds;
795 } 815 }
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