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

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

Issue 1219873002: Thread through a flag to force SkPicture::playback() when recording subpictures. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: no need to change here. Created 5 years, 5 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/SkRecorder.h ('k') | no next file » | 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 "SkBigPicture.h" 8 #include "SkBigPicture.h"
9 #include "SkCanvasPriv.h"
9 #include "SkPatchUtils.h" 10 #include "SkPatchUtils.h"
10 #include "SkPicture.h" 11 #include "SkPicture.h"
11 #include "SkPictureUtils.h" 12 #include "SkPictureUtils.h"
12 #include "SkRecorder.h" 13 #include "SkRecorder.h"
13 14
14 SkDrawableList::~SkDrawableList() { 15 SkDrawableList::~SkDrawableList() {
15 fArray.unrefAll(); 16 fArray.unrefAll();
16 } 17 }
17 18
18 SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() { 19 SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() {
19 const int count = fArray.count(); 20 const int count = fArray.count();
20 if (0 == count) { 21 if (0 == count) {
21 return NULL; 22 return NULL;
22 } 23 }
23 SkAutoTMalloc<const SkPicture*> pics(count); 24 SkAutoTMalloc<const SkPicture*> pics(count);
24 for (int i = 0; i < count; ++i) { 25 for (int i = 0; i < count; ++i) {
25 pics[i] = fArray[i]->newPictureSnapshot(); 26 pics[i] = fArray[i]->newPictureSnapshot();
26 } 27 }
27 return SkNEW_ARGS(SkBigPicture::SnapshotArray, (pics.detach(), count)); 28 return SkNEW_ARGS(SkBigPicture::SnapshotArray, (pics.detach(), count));
28 } 29 }
29 30
30 void SkDrawableList::append(SkDrawable* drawable) { 31 void SkDrawableList::append(SkDrawable* drawable) {
31 *fArray.append() = SkRef(drawable); 32 *fArray.append() = SkRef(drawable);
32 } 33 }
33 34
34 //////////////////////////////////////////////////////////////////////////////// /////////////// 35 //////////////////////////////////////////////////////////////////////////////// ///////////////
35 36
36 SkRecorder::SkRecorder(SkRecord* record, int width, int height, SkMiniRecorder* mr) 37 SkRecorder::SkRecorder(SkRecord* record, int width, int height, SkMiniRecorder* mr)
37 : SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip _InitFlag) 38 : SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip _InitFlag)
39 , fDrawPictureMode(Record_DrawPictureMode)
38 , fApproxBytesUsedBySubPictures(0) 40 , fApproxBytesUsedBySubPictures(0)
39 , fRecord(record) 41 , fRecord(record)
40 , fMiniRecorder(mr) {} 42 , fMiniRecorder(mr) {}
41 43
42 SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds, SkMiniRecorder* m r) 44 SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds, SkMiniRecorder* m r)
43 : SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag) 45 : SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag)
46 , fDrawPictureMode(Record_DrawPictureMode)
44 , fApproxBytesUsedBySubPictures(0) 47 , fApproxBytesUsedBySubPictures(0)
45 , fRecord(record) 48 , fRecord(record)
46 , fMiniRecorder(mr) {} 49 , fMiniRecorder(mr) {}
47 50
48 void SkRecorder::reset(SkRecord* record, const SkRect& bounds, SkMiniRecorder* m r) { 51 void SkRecorder::reset(SkRecord* record, const SkRect& bounds,
52 DrawPictureMode dpm, SkMiniRecorder* mr) {
49 this->forgetRecord(); 53 this->forgetRecord();
54 fDrawPictureMode = dpm;
50 fRecord = record; 55 fRecord = record;
51 this->resetForNextPicture(bounds.roundOut()); 56 this->resetForNextPicture(bounds.roundOut());
52 fMiniRecorder = mr; 57 fMiniRecorder = mr;
53 } 58 }
54 59
55 void SkRecorder::forgetRecord() { 60 void SkRecorder::forgetRecord() {
56 fDrawableList.reset(NULL); 61 fDrawableList.reset(NULL);
57 fApproxBytesUsedBySubPictures = 0; 62 fApproxBytesUsedBySubPictures = 0;
58 fRecord = NULL; 63 fRecord = NULL;
59 } 64 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 matrix ? *matrix : SkMatrix::I()); 252 matrix ? *matrix : SkMatrix::I());
248 } 253 }
249 254
250 void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, 255 void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
251 const SkPaint& paint) { 256 const SkPaint& paint) {
252 TRY_MINIRECORDER(drawTextBlob, blob, x, y, paint); 257 TRY_MINIRECORDER(drawTextBlob, blob, x, y, paint);
253 APPEND(DrawTextBlob, paint, blob, x, y); 258 APPEND(DrawTextBlob, paint, blob, x, y);
254 } 259 }
255 260
256 void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, con st SkPaint* paint) { 261 void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, con st SkPaint* paint) {
257 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic); 262 if (fDrawPictureMode == Record_DrawPictureMode) {
258 APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I() ); 263 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pi c);
264 APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix: :I());
265 } else {
266 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
267 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect());
268 pic->playback(this);
269 }
259 } 270 }
260 271
261 void SkRecorder::onDrawVertices(VertexMode vmode, 272 void SkRecorder::onDrawVertices(VertexMode vmode,
262 int vertexCount, const SkPoint vertices[], 273 int vertexCount, const SkPoint vertices[],
263 const SkPoint texs[], const SkColor colors[], 274 const SkPoint texs[], const SkColor colors[],
264 SkXfermode* xmode, 275 SkXfermode* xmode,
265 const uint16_t indices[], int indexCount, const SkPaint& paint) { 276 const uint16_t indices[], int indexCount, const SkPaint& paint) {
266 APPEND(DrawVertices, paint, 277 APPEND(DrawVertices, paint,
267 vmode, 278 vmode,
268 vertexCount, 279 vertexCount,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 INHERITED(onClipPath, path, op, edgeStyle); 351 INHERITED(onClipPath, path, op, edgeStyle);
341 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); 352 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
342 APPEND(ClipPath, this->devBounds(), path, opAA); 353 APPEND(ClipPath, this->devBounds(), path, opAA);
343 } 354 }
344 355
345 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { 356 void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
346 INHERITED(onClipRegion, deviceRgn, op); 357 INHERITED(onClipRegion, deviceRgn, op);
347 APPEND(ClipRegion, this->devBounds(), deviceRgn, op); 358 APPEND(ClipRegion, this->devBounds(), deviceRgn, op);
348 } 359 }
349 360
OLDNEW
« no previous file with comments | « src/core/SkRecorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698