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

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

Issue 736583004: allow pictures to have a full bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use new roundOut Created 6 years, 1 month 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
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 "SkData.h" 8 #include "SkData.h"
9 #include "SkLayerInfo.h" 9 #include "SkLayerInfo.h"
10 #include "SkPictureRecorder.h" 10 #include "SkPictureRecorder.h"
11 #include "SkRecord.h" 11 #include "SkRecord.h"
12 #include "SkRecordDraw.h" 12 #include "SkRecordDraw.h"
13 #include "SkRecorder.h" 13 #include "SkRecorder.h"
14 #include "SkRecordOpts.h" 14 #include "SkRecordOpts.h"
15 #include "SkTypes.h" 15 #include "SkTypes.h"
16 16
17 SkPictureRecorder::SkPictureRecorder() {} 17 SkPictureRecorder::SkPictureRecorder() {}
18 18
19 SkPictureRecorder::~SkPictureRecorder() {} 19 SkPictureRecorder::~SkPictureRecorder() {}
20 20
21 SkCanvas* SkPictureRecorder::beginRecording(SkScalar width, SkScalar height, 21 SkCanvas* SkPictureRecorder::beginRecording(const SkRect& cullRect,
22 SkBBHFactory* bbhFactory /* = NULL * /, 22 SkBBHFactory* bbhFactory /* = NULL * /,
23 uint32_t recordFlags /* = 0 */) { 23 uint32_t recordFlags /* = 0 */) {
24 fCullRect = cullRect;
24 fFlags = recordFlags; 25 fFlags = recordFlags;
25 fCullWidth = width;
26 fCullHeight = height;
27 26
28 if (bbhFactory) { 27 if (bbhFactory) {
29 fBBH.reset((*bbhFactory)(width, height)); 28 fBBH.reset((*bbhFactory)(cullRect));
30 SkASSERT(fBBH.get()); 29 SkASSERT(fBBH.get());
31 } 30 }
32 31
33 fRecord.reset(SkNEW(SkRecord)); 32 fRecord.reset(SkNEW(SkRecord));
34 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), width, height))); 33 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), cullRect)));
35 return this->getRecordingCanvas(); 34 return this->getRecordingCanvas();
36 } 35 }
37 36
38 SkCanvas* SkPictureRecorder::getRecordingCanvas() { 37 SkCanvas* SkPictureRecorder::getRecordingCanvas() {
39 return fRecorder.get(); 38 return fRecorder.get();
40 } 39 }
41 40
42 SkPicture* SkPictureRecorder::endRecording() { 41 SkPicture* SkPictureRecorder::endRecording() {
43 // TODO: delay as much of this work until just before first playback? 42 // TODO: delay as much of this work until just before first playback?
44 SkRecordOptimize(fRecord); 43 SkRecordOptimize(fRecord);
45 44
46 SkAutoTUnref<SkLayerInfo> saveLayerData; 45 SkAutoTUnref<SkLayerInfo> saveLayerData;
47 46
48 if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) { 47 if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) {
49 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); 48 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey();
50 49
51 saveLayerData.reset(SkNEW_ARGS(SkLayerInfo, (key))); 50 saveLayerData.reset(SkNEW_ARGS(SkLayerInfo, (key)));
52 } 51 }
53 52
54 if (fBBH.get()) { 53 if (fBBH.get()) {
55 SkRect cullRect = SkRect::MakeWH(fCullWidth, fCullHeight);
56
57 if (saveLayerData) { 54 if (saveLayerData) {
58 SkRecordComputeLayers(cullRect, *fRecord, fBBH.get(), saveLayerData) ; 55 SkRecordComputeLayers(fCullRect, *fRecord, fBBH.get(), saveLayerData );
59 } else { 56 } else {
60 SkRecordFillBounds(cullRect, *fRecord, fBBH.get()); 57 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
61 } 58 }
62 } 59 }
63 60
64 // TODO: we should remember these from our caller 61 // TODO: we should remember these from our caller
65 SkBBHFactory* factory = NULL; 62 SkBBHFactory* factory = NULL;
66 uint32_t recordFlags = 0; 63 uint32_t recordFlags = 0;
67 SkAutoDataUnref drawablePicts(fRecorder->newDrawableSnapshot(factory, record Flags)); 64 SkAutoDataUnref drawablePicts(fRecorder->newDrawableSnapshot(factory, record Flags));
68 SkPicture* pict = SkNEW_ARGS(SkPicture, (fCullWidth, fCullHeight, fRecord.de tach(), 65 SkPicture* pict = SkNEW_ARGS(SkPicture, (fCullRect, fRecord.detach(),
69 drawablePicts, fBBH.get())); 66 drawablePicts, fBBH.get()));
70 67
71 if (saveLayerData) { 68 if (saveLayerData) {
72 pict->EXPERIMENTAL_addAccelData(saveLayerData); 69 pict->EXPERIMENTAL_addAccelData(saveLayerData);
73 } 70 }
74 71
75 return pict; 72 return pict;
76 } 73 }
77 74
78 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 75 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
79 if (NULL == canvas) { 76 if (NULL == canvas) {
80 return; 77 return;
81 } 78 }
82 79
83 int drawableCount = 0; 80 int drawableCount = 0;
84 SkRecordDraw(*fRecord, canvas, NULL, drawableCount, NULL/*bbh*/, NULL/*callb ack*/); 81 SkRecordDraw(*fRecord, canvas, NULL, drawableCount, NULL/*bbh*/, NULL/*callb ack*/);
85 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698