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

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

Issue 1978533002: Remove SkPicture::hasText() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/SkBigPicture.cpp ('k') | src/core/SkPictureCommon.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 2015 Google Inc. 2 * Copyright 2015 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 "SkTLazy.h" 9 #include "SkTLazy.h"
10 #include "SkMiniRecorder.h" 10 #include "SkMiniRecorder.h"
11 #include "SkOnce.h" 11 #include "SkOnce.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkPictureCommon.h" 13 #include "SkPictureCommon.h"
14 #include "SkRecordDraw.h" 14 #include "SkRecordDraw.h"
15 #include "SkTextBlob.h" 15 #include "SkTextBlob.h"
16 16
17 using namespace SkRecords; 17 using namespace SkRecords;
18 18
19 class SkEmptyPicture final : public SkPicture { 19 class SkEmptyPicture final : public SkPicture {
20 public: 20 public:
21 void playback(SkCanvas*, AbortCallback*) const override { } 21 void playback(SkCanvas*, AbortCallback*) const override { }
22 22
23 size_t approximateBytesUsed() const override { return sizeof(*this); } 23 size_t approximateBytesUsed() const override { return sizeof(*this); }
24 int approximateOpCount() const override { return 0; } 24 int approximateOpCount() const override { return 0; }
25 SkRect cullRect() const override { return SkRect::MakeEmpty(); } 25 SkRect cullRect() const override { return SkRect::MakeEmpty(); }
26 bool hasText() const override { return false; }
27 int numSlowPaths() const override { return 0; } 26 int numSlowPaths() const override { return 0; }
28 bool willPlayBackBitmaps() const override { return false; } 27 bool willPlayBackBitmaps() const override { return false; }
29 }; 28 };
30 29
31 template <typename T> 30 template <typename T>
32 class SkMiniPicture final : public SkPicture { 31 class SkMiniPicture final : public SkPicture {
33 public: 32 public:
34 SkMiniPicture(SkRect cull, T* op) : fCull(cull) { 33 SkMiniPicture(SkRect cull, T* op) : fCull(cull) {
35 memcpy(&fOp, op, sizeof(fOp)); // We take ownership of op's guts. 34 memcpy(&fOp, op, sizeof(fOp)); // We take ownership of op's guts.
36 } 35 }
37 36
38 void playback(SkCanvas* c, AbortCallback*) const override { 37 void playback(SkCanvas* c, AbortCallback*) const override {
39 SkRecords::Draw(c, nullptr, nullptr, 0, nullptr)(fOp); 38 SkRecords::Draw(c, nullptr, nullptr, 0, nullptr)(fOp);
40 } 39 }
41 40
42 size_t approximateBytesUsed() const override { return sizeof(*this); } 41 size_t approximateBytesUsed() const override { return sizeof(*this); }
43 int approximateOpCount() const override { return 1; } 42 int approximateOpCount() const override { return 1; }
44 SkRect cullRect() const override { return fCull; } 43 SkRect cullRect() const override { return fCull; }
45 bool hasText() const override { return SkTextHunter()(fOp); }
46 bool willPlayBackBitmaps() const override { return SkBitmapHunter()(fOp); } 44 bool willPlayBackBitmaps() const override { return SkBitmapHunter()(fOp); }
47 int numSlowPaths() const override { 45 int numSlowPaths() const override {
48 SkPathCounter counter; 46 SkPathCounter counter;
49 counter(fOp); 47 counter(fOp);
50 return counter.fNumSlowPathsAndDashEffects; 48 return counter.fNumSlowPathsAndDashEffects;
51 } 49 }
52 50
53 private: 51 private:
54 SkRect fCull; 52 SkRect fCull;
55 T fOp; 53 T fOp;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 switch (fState) { 133 switch (fState) {
136 case State::kEmpty: return; 134 case State::kEmpty: return;
137 CASE(DrawBitmapRectFixedSize); 135 CASE(DrawBitmapRectFixedSize);
138 CASE(DrawPath); 136 CASE(DrawPath);
139 CASE(DrawRect); 137 CASE(DrawRect);
140 CASE(DrawTextBlob); 138 CASE(DrawTextBlob);
141 } 139 }
142 SkASSERT(false); 140 SkASSERT(false);
143 #undef CASE 141 #undef CASE
144 } 142 }
OLDNEW
« no previous file with comments | « src/core/SkBigPicture.cpp ('k') | src/core/SkPictureCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698