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

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

Issue 435093003: Keep track of the number of skia operations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Keep track of op count for 396908 Created 6 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/SkPictureContentInfo.h ('k') | src/core/SkPictureData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2011 Google Inc.
mtklein 2014/08/02 14:06:28 2014?
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 "SkPaint.h"
9 #include "SkPathEffect.h"
10 #include "SkPictureContentInfo.h"
11
12 bool SkPictureContentInfo::suitableForGpuRasterization(GrContext* context, const char **reason,
13 int sampleCount) const {
14 // TODO: the heuristic used here needs to be refined
15 static const int kNumPaintWithPathEffectUsesTol = 1;
16 static const int kNumAAConcavePaths = 5;
17
18 SkASSERT(fNumAAHairlineConcavePaths <= fNumAAConcavePaths);
19
20 int numNonDashedPathEffects = fNumPaintWithPathEffectUses -
21 fNumFastPathDashEffects;
22
23 bool suitableForDash = (0 == fNumPaintWithPathEffectUses) ||
24 (numNonDashedPathEffects < kNumPaintWithPathEffectUse sTol
25 && 0 == sampleCount);
26
27 bool ret = suitableForDash &&
28 (fNumAAConcavePaths - fNumAAHairlineConcavePaths)
29 < kNumAAConcavePaths;
30 if (!ret && NULL != reason) {
31 if (!suitableForDash) {
32 if (0 != sampleCount) {
33 *reason = "Can't use multisample on dash effect.";
34 } else {
35 *reason = "Too many non dashed path effects.";
36 }
37 } else if ((fNumAAConcavePaths - fNumAAHairlineConcavePaths)
38 >= kNumAAConcavePaths) {
39 *reason = "Too many anti-aliased concave paths.";
40 } else {
41 *reason = "Unknown reason for GPU unsuitability.";
42 }
43 }
44 return ret;
45 }
46
47 void SkPictureContentInfo::onDrawPoints(size_t count, const SkPaint& paint) {
48 if (paint.getPathEffect() != NULL) {
49 SkPathEffect::DashInfo info;
50 SkPathEffect::DashType dashType = paint.getPathEffect()->asADash(&info);
51 if (2 == count && SkPaint::kRound_Cap != paint.getStrokeCap() &&
52 SkPathEffect::kDash_DashType == dashType && 2 == info.fCount) {
53 ++fNumFastPathDashEffects;
54 }
55 }
56 }
57
58 void SkPictureContentInfo::onDrawPath(const SkPath& path, const SkPaint& paint) {
59 if (paint.isAntiAlias() && !path.isConvex()) {
60 ++fNumAAConcavePaths;
61
62 if (SkPaint::kStroke_Style == paint.getStyle() &&
63 0 == paint.getStrokeWidth()) {
64 ++fNumAAHairlineConcavePaths;
65 }
66 }
67 }
68
69 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) {
70 if (NULL != paint && NULL != paint->getPathEffect()) {
71 ++fNumPaintWithPathEffectUses;
72 }
73 }
74
75 void SkPictureContentInfo::set(const SkPictureContentInfo& src) {
76 fNumOperations = src.fNumOperations;
77 fNumTexts = src.fNumTexts;
78 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
79 fNumFastPathDashEffects = src.fNumFastPathDashEffects;
80 fNumAAConcavePaths = src.fNumAAConcavePaths;
81 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
82 }
83
84 void SkPictureContentInfo::reset() {
85 fNumOperations = 0;
86 fNumTexts = 0;
87 fNumPaintWithPathEffectUses = 0;
88 fNumFastPathDashEffects = 0;
89 fNumAAConcavePaths = 0;
90 fNumAAHairlineConcavePaths = 0;
91 }
92
93 void SkPictureContentInfo::swap(SkPictureContentInfo* other) {
94 SkTSwap(fNumOperations, other->fNumOperations);
95 SkTSwap(fNumTexts, other->fNumTexts);
96 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects);
97 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
98 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths);
99 }
OLDNEW
« no previous file with comments | « src/core/SkPictureContentInfo.h ('k') | src/core/SkPictureData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698