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

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

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

Powered by Google App Engine
This is Rietveld 408576698