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

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: Fixed the return type of numOperations 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 2014 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 "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() && 0 == paint.getStrokeWi dth()) {
63 ++fNumAAHairlineConcavePaths;
64 }
65 }
66 }
67
68 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) {
69 if (NULL != paint && NULL != paint->getPathEffect()) {
70 ++fNumPaintWithPathEffectUses;
71 }
72 }
73
74 void SkPictureContentInfo::set(const SkPictureContentInfo& src) {
75 fNumOperations = src.fNumOperations;
76 fNumTexts = src.fNumTexts;
77 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
78 fNumFastPathDashEffects = src.fNumFastPathDashEffects;
79 fNumAAConcavePaths = src.fNumAAConcavePaths;
80 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
81 }
82
83 void SkPictureContentInfo::reset() {
84 fNumOperations = 0;
85 fNumTexts = 0;
86 fNumPaintWithPathEffectUses = 0;
87 fNumFastPathDashEffects = 0;
88 fNumAAConcavePaths = 0;
89 fNumAAHairlineConcavePaths = 0;
90 }
91
92 void SkPictureContentInfo::swap(SkPictureContentInfo* other) {
93 SkTSwap(fNumOperations, other->fNumOperations);
94 SkTSwap(fNumTexts, other->fNumTexts);
95 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses);
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