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

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

Issue 464433002: Add layer counting to SkPictureRecord (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix bug 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
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkPaint.h" 8 #include "SkPaint.h"
9 #include "SkPathEffect.h" 9 #include "SkPathEffect.h"
10 #include "SkPictureContentInfo.h" 10 #include "SkPictureContentInfo.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 64 }
65 } 65 }
66 } 66 }
67 67
68 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) { 68 void SkPictureContentInfo::onAddPaintPtr(const SkPaint* paint) {
69 if (NULL != paint && NULL != paint->getPathEffect()) { 69 if (NULL != paint && NULL != paint->getPathEffect()) {
70 ++fNumPaintWithPathEffectUses; 70 ++fNumPaintWithPathEffectUses;
71 } 71 }
72 } 72 }
73 73
74 void SkPictureContentInfo::onSaveLayer() {
75 *fSaveStack.append() = kSaveLayer_Flag;
76 }
77
78 void SkPictureContentInfo::onSave() {
79 *fSaveStack.append() = kSave_Flag;
80 }
81
82 void SkPictureContentInfo::onRestore() {
83 SkASSERT(fSaveStack.count() > 0);
84
85 bool containedSaveLayer = fSaveStack.top() & kContainedSaveLayer_Flag;
86
87 if (fSaveStack.top() & kSaveLayer_Flag) {
88 ++fNumLayers;
89 if (containedSaveLayer) {
90 ++fNumInteriorLayers;
91 } else {
92 ++fNumLeafLayers;
93 }
94 containedSaveLayer = true;
95 }
96
97 fSaveStack.pop();
98
99 if (containedSaveLayer && fSaveStack.count() > 0) {
100 fSaveStack.top() |= kContainedSaveLayer_Flag;
101 }
102 }
103
104 void SkPictureContentInfo::rescindLastSave() {
105 SkASSERT(fSaveStack.count() > 0);
106 SkASSERT(fSaveStack.top() & kSave_Flag);
107
108 bool containedSaveLayer = fSaveStack.top() & kContainedSaveLayer_Flag;
109
110 fSaveStack.pop();
111
112 if (containedSaveLayer && fSaveStack.count() > 0) {
113 fSaveStack.top() |= kContainedSaveLayer_Flag;
114 }
115 }
116
117 void SkPictureContentInfo::rescindLastSaveLayer() {
118 SkASSERT(fSaveStack.count() > 0);
119 SkASSERT(fSaveStack.top() & kSaveLayer_Flag);
120
121 bool containedSaveLayer = fSaveStack.top() & kContainedSaveLayer_Flag;
122
123 fSaveStack.pop();
124
125 if (containedSaveLayer && fSaveStack.count() > 0) {
126 fSaveStack.top() |= kContainedSaveLayer_Flag;
127 }
128 }
129
74 void SkPictureContentInfo::set(const SkPictureContentInfo& src) { 130 void SkPictureContentInfo::set(const SkPictureContentInfo& src) {
75 fNumOperations = src.fNumOperations; 131 fNumOperations = src.fNumOperations;
76 fNumTexts = src.fNumTexts; 132 fNumTexts = src.fNumTexts;
77 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses; 133 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses;
78 fNumFastPathDashEffects = src.fNumFastPathDashEffects; 134 fNumFastPathDashEffects = src.fNumFastPathDashEffects;
79 fNumAAConcavePaths = src.fNumAAConcavePaths; 135 fNumAAConcavePaths = src.fNumAAConcavePaths;
80 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths; 136 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths;
137 fNumLayers = src.fNumLayers;
138 fNumInteriorLayers = src.fNumInteriorLayers;
139 fNumLeafLayers = src.fNumLeafLayers;
140 fSaveStack = src.fSaveStack;
81 } 141 }
82 142
83 void SkPictureContentInfo::reset() { 143 void SkPictureContentInfo::reset() {
84 fNumOperations = 0; 144 fNumOperations = 0;
85 fNumTexts = 0; 145 fNumTexts = 0;
86 fNumPaintWithPathEffectUses = 0; 146 fNumPaintWithPathEffectUses = 0;
87 fNumFastPathDashEffects = 0; 147 fNumFastPathDashEffects = 0;
88 fNumAAConcavePaths = 0; 148 fNumAAConcavePaths = 0;
89 fNumAAHairlineConcavePaths = 0; 149 fNumAAHairlineConcavePaths = 0;
150 fNumLayers = 0;
151 fNumInteriorLayers = 0;
152 fNumLeafLayers = 0;
153 fSaveStack.rewind();
90 } 154 }
91 155
92 void SkPictureContentInfo::swap(SkPictureContentInfo* other) { 156 void SkPictureContentInfo::swap(SkPictureContentInfo* other) {
93 SkTSwap(fNumOperations, other->fNumOperations); 157 SkTSwap(fNumOperations, other->fNumOperations);
94 SkTSwap(fNumTexts, other->fNumTexts); 158 SkTSwap(fNumTexts, other->fNumTexts);
95 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses); 159 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses);
96 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects); 160 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects);
97 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths); 161 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths);
98 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths); 162 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths);
163 SkTSwap(fNumLayers, other->fNumLayers);
164 SkTSwap(fNumInteriorLayers, other->fNumInteriorLayers);
165 SkTSwap(fNumLeafLayers, other->fNumLeafLayers);
166 fSaveStack.swap(other->fSaveStack);
99 } 167 }
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