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

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

Issue 2000423005: Complex clipPath accounting (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: review 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 | « include/core/SkPictureAnalyzer.h ('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 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 "SkPath.h"
8 #include "SkPicture.h" 9 #include "SkPicture.h"
9 #include "SkPictureAnalyzer.h" 10 #include "SkPictureAnalyzer.h"
11 #include "SkPictureCommon.h"
12 #include "SkRecords.h"
10 13
11 #if SK_SUPPORT_GPU 14 #if SK_SUPPORT_GPU
12 15
13 namespace { 16 namespace {
14 17
15 inline bool veto_predicate(uint32_t numSlowPaths) { 18 inline bool veto_predicate(uint32_t numSlowPaths) {
16 return numSlowPaths > 5; 19 return numSlowPaths > 5;
17 } 20 }
18 21
19 } // anonymous namespace 22 } // anonymous namespace
20 23
21 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> /* un used ATM */) 24 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> /* un used ATM */)
22 : fNumSlowPaths(0) { } 25 : fNumSlowPaths(0) { }
23 26
24 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture, 27 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture,
25 sk_sp<GrContextThreadSafeProxy> ctx) 28 sk_sp<GrContextThreadSafeProxy> ctx)
26 : SkPictureGpuAnalyzer(std::move(ctx)) { 29 : SkPictureGpuAnalyzer(std::move(ctx)) {
27 this->analyze(picture.get()); 30 this->analyze(picture.get());
28 } 31 }
29 32
30 void SkPictureGpuAnalyzer::analyze(const SkPicture* picture) { 33 void SkPictureGpuAnalyzer::analyzePicture(const SkPicture* picture) {
31 if (!picture || veto_predicate(fNumSlowPaths)) { 34 if (!picture || veto_predicate(fNumSlowPaths)) {
32 return; 35 return;
33 } 36 }
34 37
35 fNumSlowPaths += picture->numSlowPaths(); 38 fNumSlowPaths += picture->numSlowPaths();
36 } 39 }
37 40
41 void SkPictureGpuAnalyzer::analyzeClipPath(const SkPath& path, SkRegion::Op op, bool doAntiAlias) {
42 if (veto_predicate(fNumSlowPaths)) {
43 return;
44 }
45
46 const SkRecords::ClipPath clipOp = {
47 SkIRect::MakeEmpty(), // Willie don't care.
48 path,
49 SkRecords::RegionOpAndAA(op, doAntiAlias)
50 };
51
52 SkPathCounter counter;
53 counter(clipOp);
54 fNumSlowPaths += counter.fNumSlowPathsAndDashEffects;
55 }
56
38 void SkPictureGpuAnalyzer::reset() { 57 void SkPictureGpuAnalyzer::reset() {
39 fNumSlowPaths = 0; 58 fNumSlowPaths = 0;
40 } 59 }
41 60
42 bool SkPictureGpuAnalyzer::suitableForGpuRasterization(const char** whyNot) cons t { 61 bool SkPictureGpuAnalyzer::suitableForGpuRasterization(const char** whyNot) cons t {
43 if(veto_predicate(fNumSlowPaths)) { 62 if(veto_predicate(fNumSlowPaths)) {
44 if (whyNot) { *whyNot = "Too many slow paths (either concave or dashed). "; } 63 if (whyNot) { *whyNot = "Too many slow paths (either concave or dashed). "; }
45 return false; 64 return false;
46 } 65 }
47 return true; 66 return true;
48 } 67 }
49 68
50 #endif // SK_SUPPORT_GPU 69 #endif // SK_SUPPORT_GPU
OLDNEW
« no previous file with comments | « include/core/SkPictureAnalyzer.h ('k') | src/core/SkPictureCommon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698