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

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

Issue 251533004: First pass at GPU veto (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add counting of AA hairline stroked concave paths Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPictureRecord.cpp » ('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 /* 2 /*
3 * Copyright 2007 The Android Open Source Project 3 * Copyright 2007 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkPictureFlat.h" 10 #include "SkPictureFlat.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 SkASSERT(scaleX == 0 || skewX == 0); 115 SkASSERT(scaleX == 0 || skewX == 0);
116 SkASSERT(scaleY == 0 || skewY == 0); 116 SkASSERT(scaleY == 0 || skewY == 0);
117 SkASSERT(perspX == 0); 117 SkASSERT(perspX == 0);
118 SkASSERT(perspY == 0); 118 SkASSERT(perspY == 0);
119 } 119 }
120 #endif 120 #endif
121 121
122 122
123 /////////////////////////////////////////////////////////////////////////////// 123 ///////////////////////////////////////////////////////////////////////////////
124 124
125 SkPicture::SkPicture() { 125 SkPicture::SkPicture()
126 : fAccelData(NULL) {
126 this->needsNewGenID(); 127 this->needsNewGenID();
127 fRecord = NULL; 128 fRecord = NULL;
128 fPlayback = NULL; 129 fPlayback = NULL;
129 fWidth = fHeight = 0; 130 fWidth = fHeight = 0;
130 fAccelData = NULL;
131 } 131 }
132 132
133 SkPicture::SkPicture(const SkPicture& src) 133 SkPicture::SkPicture(const SkPicture& src)
134 : INHERITED() 134 : INHERITED()
135 , fAccelData(NULL) { 135 , fAccelData(NULL)
136 , fContentInfo(src.fContentInfo) {
136 this->needsNewGenID(); 137 this->needsNewGenID();
137 fWidth = src.fWidth; 138 fWidth = src.fWidth;
138 fHeight = src.fHeight; 139 fHeight = src.fHeight;
139 fRecord = NULL; 140 fRecord = NULL;
140 141
141 /* We want to copy the src's playback. However, if that hasn't been built 142 /* We want to copy the src's playback. However, if that hasn't been built
142 yet, we need to fake a call to endRecording() without actually calling 143 yet, we need to fake a call to endRecording() without actually calling
143 it (since it is destructive, and we don't want to change src). 144 it (since it is destructive, and we don't want to change src).
144 */ 145 */
145 if (src.fPlayback) { 146 if (src.fPlayback) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 201 }
201 202
202 void SkPicture::swap(SkPicture& other) { 203 void SkPicture::swap(SkPicture& other) {
203 SkTSwap(fUniqueID, other.fUniqueID); 204 SkTSwap(fUniqueID, other.fUniqueID);
204 SkTSwap(fRecord, other.fRecord); 205 SkTSwap(fRecord, other.fRecord);
205 SkTSwap(fPlayback, other.fPlayback); 206 SkTSwap(fPlayback, other.fPlayback);
206 SkTSwap(fAccelData, other.fAccelData); 207 SkTSwap(fAccelData, other.fAccelData);
207 SkTSwap(fWidth, other.fWidth); 208 SkTSwap(fWidth, other.fWidth);
208 SkTSwap(fHeight, other.fHeight); 209 SkTSwap(fHeight, other.fHeight);
209 fPathHeap.swap(&other.fPathHeap); 210 fPathHeap.swap(&other.fPathHeap);
211 fContentInfo.swap(&other.fContentInfo);
210 } 212 }
211 213
212 SkPicture* SkPicture::clone() const { 214 SkPicture* SkPicture::clone() const {
213 SkPicture* clonedPicture = SkNEW(SkPicture); 215 SkPicture* clonedPicture = SkNEW(SkPicture);
214 this->clone(clonedPicture, 1); 216 this->clone(clonedPicture, 1);
215 return clonedPicture; 217 return clonedPicture;
216 } 218 }
217 219
218 void SkPicture::clone(SkPicture* pictures, int count) const { 220 void SkPicture::clone(SkPicture* pictures, int count) const {
219 SkPictCopyInfo copyInfo; 221 SkPictCopyInfo copyInfo;
220 SkPictInfo info; 222 SkPictInfo info;
221 this->createHeader(&info); 223 this->createHeader(&info);
222 224
223 for (int i = 0; i < count; i++) { 225 for (int i = 0; i < count; i++) {
224 SkPicture* clone = &pictures[i]; 226 SkPicture* clone = &pictures[i];
225 227
226 clone->needsNewGenID(); 228 clone->needsNewGenID();
227 clone->fWidth = fWidth; 229 clone->fWidth = fWidth;
228 clone->fHeight = fHeight; 230 clone->fHeight = fHeight;
229 SkSafeSetNull(clone->fRecord); 231 SkSafeSetNull(clone->fRecord);
230 SkDELETE(clone->fPlayback); 232 SkDELETE(clone->fPlayback);
233 clone->fContentInfo.set(fContentInfo);
231 234
232 /* We want to copy the src's playback. However, if that hasn't been bui lt 235 /* We want to copy the src's playback. However, if that hasn't been bui lt
233 yet, we need to fake a call to endRecording() without actually calli ng 236 yet, we need to fake a call to endRecording() without actually calli ng
234 it (since it is destructive, and we don't want to change src). 237 it (since it is destructive, and we don't want to change src).
235 */ 238 */
236 if (fPlayback) { 239 if (fPlayback) {
237 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (clone, *fPlayback, &copyInfo)); 240 clone->fPlayback = SkNEW_ARGS(SkPicturePlayback, (clone, *fPlayback, &copyInfo));
238 SkASSERT(NULL == fRecord); 241 SkASSERT(NULL == fRecord);
239 clone->fUniqueID = this->uniqueID(); // need to call method to ensur e != 0 242 clone->fUniqueID = this->uniqueID(); // need to call method to ensur e != 0
240 } else if (fRecord) { 243 } else if (fRecord) {
(...skipping 23 matching lines...) Expand all
264 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES 267 #ifdef SK_SUPPORT_LEGACY_DERIVED_PICTURE_CLASSES
265 268
266 SkCanvas* SkPicture::beginRecording(int width, int height, 269 SkCanvas* SkPicture::beginRecording(int width, int height,
267 uint32_t recordingFlags) { 270 uint32_t recordingFlags) {
268 if (fPlayback) { 271 if (fPlayback) {
269 SkDELETE(fPlayback); 272 SkDELETE(fPlayback);
270 fPlayback = NULL; 273 fPlayback = NULL;
271 } 274 }
272 SkSafeUnref(fAccelData); 275 SkSafeUnref(fAccelData);
273 SkSafeSetNull(fRecord); 276 SkSafeSetNull(fRecord);
277 fContentInfo.reset();
274 278
275 this->needsNewGenID(); 279 this->needsNewGenID();
276 280
277 // Must be set before calling createBBoxHierarchy 281 // Must be set before calling createBBoxHierarchy
278 fWidth = width; 282 fWidth = width;
279 fHeight = height; 283 fHeight = height;
280 284
281 const SkISize size = SkISize::Make(width, height); 285 const SkISize size = SkISize::Make(width, height);
282 286
283 if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) { 287 if (recordingFlags & kOptimizeForClippedPlayback_RecordingFlag) {
(...skipping 14 matching lines...) Expand all
298 SkCanvas* SkPicture::beginRecording(int width, int height, 302 SkCanvas* SkPicture::beginRecording(int width, int height,
299 SkBBHFactory* bbhFactory, 303 SkBBHFactory* bbhFactory,
300 uint32_t recordingFlags) { 304 uint32_t recordingFlags) {
301 if (fPlayback) { 305 if (fPlayback) {
302 SkDELETE(fPlayback); 306 SkDELETE(fPlayback);
303 fPlayback = NULL; 307 fPlayback = NULL;
304 } 308 }
305 SkSafeUnref(fAccelData); 309 SkSafeUnref(fAccelData);
306 SkSafeSetNull(fRecord); 310 SkSafeSetNull(fRecord);
307 SkASSERT(NULL == fPathHeap); 311 SkASSERT(NULL == fPathHeap);
312 fContentInfo.reset();
308 313
309 this->needsNewGenID(); 314 this->needsNewGenID();
310 315
311 fWidth = width; 316 fWidth = width;
312 fHeight = height; 317 fHeight = height;
313 318
314 const SkISize size = SkISize::Make(width, height); 319 const SkISize size = SkISize::Make(width, height);
315 320
316 if (NULL != bbhFactory) { 321 if (NULL != bbhFactory) {
317 SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height)); 322 SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 if (playback != fPlayback) { 600 if (playback != fPlayback) {
596 SkDELETE(playback); 601 SkDELETE(playback);
597 } 602 }
598 } else { 603 } else {
599 buffer.writeBool(false); 604 buffer.writeBool(false);
600 } 605 }
601 } 606 }
602 607
603 #if SK_SUPPORT_GPU 608 #if SK_SUPPORT_GPU
604 bool SkPicture::suitableForGpuRasterization(GrContext* context) const { 609 bool SkPicture::suitableForGpuRasterization(GrContext* context) const {
605 // Stub for now; never veto GPu rasterization. 610 // TODO: the heuristic used here needs to be refined
606 return true; 611 static const int kNumPaintWithPathEffectUsesTol = 1;
612 static const int kNumAAConcavePaths = 5;
613
614 SkASSERT(this->numAAHairlineConcavePaths() <= this->numAAConcavePaths());
615
616 return this->numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol & &
617 (this->numAAConcavePaths()-this->numAAHairlineConcavePaths()) < kNumA AConcavePaths;
607 } 618 }
608 #endif 619 #endif
609 620
610 bool SkPicture::willPlayBackBitmaps() const { 621 bool SkPicture::willPlayBackBitmaps() const {
611 if (!fPlayback) { 622 if (!fPlayback) {
612 return false; 623 return false;
613 } 624 }
614 return fPlayback->containsBitmaps(); 625 return fPlayback->containsBitmaps();
615 } 626 }
616 627
(...skipping 21 matching lines...) Expand all
638 if (NULL != fRecord) { 649 if (NULL != fRecord) {
639 SkASSERT(NULL == fPlayback); 650 SkASSERT(NULL == fPlayback);
640 return SK_InvalidGenID; 651 return SK_InvalidGenID;
641 } 652 }
642 653
643 if (SK_InvalidGenID == fUniqueID) { 654 if (SK_InvalidGenID == fUniqueID) {
644 fUniqueID = next_picture_generation_id(); 655 fUniqueID = next_picture_generation_id();
645 } 656 }
646 return fUniqueID; 657 return fUniqueID;
647 } 658 }
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPictureRecord.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698