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

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

Issue 266203003: Infrastructure changes to support pull saveLayers forward task (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fixed Android error Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPaintPriv.cpp ('k') | src/gpu/GrPictureUtils.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 /* 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"
11 #include "SkPicturePlayback.h" 11 #include "SkPicturePlayback.h"
12 #include "SkPictureRecord.h" 12 #include "SkPictureRecord.h"
13 13
14 #include "SkBBHFactory.h" 14 #include "SkBBHFactory.h"
15 #include "SkBitmapDevice.h" 15 #include "SkBitmapDevice.h"
16 #include "SkCanvas.h" 16 #include "SkCanvas.h"
17 #include "SkChunkAlloc.h" 17 #include "SkChunkAlloc.h"
18 #include "SkPaintPriv.h"
18 #include "SkPicture.h" 19 #include "SkPicture.h"
19 #include "SkRegion.h" 20 #include "SkRegion.h"
20 #include "SkStream.h" 21 #include "SkStream.h"
21 #include "SkTDArray.h" 22 #include "SkTDArray.h"
22 #include "SkTSearch.h" 23 #include "SkTSearch.h"
23 #include "SkTime.h" 24 #include "SkTime.h"
24 25
25 #include "SkReader32.h" 26 #include "SkReader32.h"
26 #include "SkWriter32.h" 27 #include "SkWriter32.h"
27 #include "SkRTree.h" 28 #include "SkRTree.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 fPathHeap.swap(&other.fPathHeap); 211 fPathHeap.swap(&other.fPathHeap);
211 fContentInfo.swap(&other.fContentInfo); 212 fContentInfo.swap(&other.fContentInfo);
212 } 213 }
213 214
214 SkPicture* SkPicture::clone() const { 215 SkPicture* SkPicture::clone() const {
215 SkPicture* clonedPicture = SkNEW(SkPicture); 216 SkPicture* clonedPicture = SkNEW(SkPicture);
216 this->clone(clonedPicture, 1); 217 this->clone(clonedPicture, 1);
217 return clonedPicture; 218 return clonedPicture;
218 } 219 }
219 220
220 static bool needs_deep_copy(const SkPaint& paint) {
221 /*
222 * These fields are known to be immutable, and so can be shallow-copied
223 *
224 * getTypeface()
225 * getAnnotation()
226 * paint.getColorFilter()
227 * getXfermode()
228 * getPathEffect()
229 * getMaskFilter()
230 */
231
232 return paint.getShader() ||
233 #ifdef SK_SUPPORT_LEGACY_LAYERRASTERIZER_API
234 paint.getRasterizer() ||
235 #endif
236 paint.getLooper() || // needs to hide its addLayer...
237 paint.getImageFilter();
238 }
239
240 void SkPicture::clone(SkPicture* pictures, int count) const { 221 void SkPicture::clone(SkPicture* pictures, int count) const {
241 SkPictCopyInfo copyInfo; 222 SkPictCopyInfo copyInfo;
242 SkPictInfo info; 223 SkPictInfo info;
243 this->createHeader(&info); 224 this->createHeader(&info);
244 225
245 for (int i = 0; i < count; i++) { 226 for (int i = 0; i < count; i++) {
246 SkPicture* clone = &pictures[i]; 227 SkPicture* clone = &pictures[i];
247 228
248 clone->needsNewGenID(); 229 clone->needsNewGenID();
249 clone->fWidth = fWidth; 230 clone->fWidth = fWidth;
(...skipping 25 matching lines...) Expand all
275 // FIXME: Put this on the stack inside SkPicture::clone. 256 // FIXME: Put this on the stack inside SkPicture::clone.
276 SkBitmapHeap* heap = SkNEW(SkBitmapHeap); 257 SkBitmapHeap* heap = SkNEW(SkBitmapHeap);
277 copyInfo.controller.setBitmapStorage(heap); 258 copyInfo.controller.setBitmapStorage(heap);
278 heap->unref(); 259 heap->unref();
279 } else { 260 } else {
280 copyInfo.controller.setBitmapStorage(fPlayback->fBitmapHeap) ; 261 copyInfo.controller.setBitmapStorage(fPlayback->fBitmapHeap) ;
281 } 262 }
282 263
283 SkDEBUGCODE(int heapSize = SafeCount(fPlayback->fBitmapHeap.get( ));) 264 SkDEBUGCODE(int heapSize = SafeCount(fPlayback->fBitmapHeap.get( ));)
284 for (int i = 0; i < paintCount; i++) { 265 for (int i = 0; i < paintCount; i++) {
285 if (needs_deep_copy(fPlayback->fPaints->at(i))) { 266 if (NeedsDeepCopy(fPlayback->fPaints->at(i))) {
286 copyInfo.paintData[i] = 267 copyInfo.paintData[i] =
287 SkFlatData::Create<SkPaint::FlatteningTraits>(&copyI nfo.controller, 268 SkFlatData::Create<SkPaint::FlatteningTraits>(&copyI nfo.controller,
288 fPlayback->fPaints ->at(i), 0); 269 fPlayback->fPaints ->at(i), 0);
289 270
290 } else { 271 } else {
291 // this is our sentinel, which we use in the unflatten l oop 272 // this is our sentinel, which we use in the unflatten l oop
292 copyInfo.paintData[i] = NULL; 273 copyInfo.paintData[i] = NULL;
293 } 274 }
294 } 275 }
295 SkASSERT(SafeCount(fPlayback->fBitmapHeap.get()) == heapSize); 276 SkASSERT(SafeCount(fPlayback->fBitmapHeap.get()) == heapSize);
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 if (NULL != fRecord) { 692 if (NULL != fRecord) {
712 SkASSERT(NULL == fPlayback); 693 SkASSERT(NULL == fPlayback);
713 return SK_InvalidGenID; 694 return SK_InvalidGenID;
714 } 695 }
715 696
716 if (SK_InvalidGenID == fUniqueID) { 697 if (SK_InvalidGenID == fUniqueID) {
717 fUniqueID = next_picture_generation_id(); 698 fUniqueID = next_picture_generation_id();
718 } 699 }
719 return fUniqueID; 700 return fUniqueID;
720 } 701 }
OLDNEW
« no previous file with comments | « src/core/SkPaintPriv.cpp ('k') | src/gpu/GrPictureUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698