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

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

Issue 1974833003: SkPictureGpuAnalyzer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: unneeded 'explicit' 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkPicture.h"
9 #include "SkPictureAnalyzer.h"
10
11 namespace {
12
13 inline bool veto_predicate(uint32_t numSlowPaths) {
14 return numSlowPaths > 5;
15 }
16
17 } // anonymous namespace
18
19 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer()
20 : fNumSlowPaths(0) { }
21
22 SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture)
23 : SkPictureGpuAnalyzer() {
24 this->analyze(picture.get());
25 }
26
27 void SkPictureGpuAnalyzer::analyze(const SkPicture* picture) {
28 if (!picture || veto_predicate(fNumSlowPaths)) {
29 return;
30 }
31
32 fNumSlowPaths += picture->numSlowPaths();
33 }
34
35 void SkPictureGpuAnalyzer::reset() {
36 fNumSlowPaths = 0;
37 }
38
39 bool SkPictureGpuAnalyzer::suitableForGpuRasterization(GrContext*, const char** whyNot) const {
40 if(veto_predicate(fNumSlowPaths)) {
41 if (whyNot) { *whyNot = "Too many slow paths (either concave or dashed). "; }
42 return false;
43 }
44 return true;
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698