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

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

Issue 454123003: Plumbing for using a BBH in SkRecordDraw. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clang says asserts are always true Created 6 years, 4 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/SkPicture.cpp ('k') | src/core/SkRecordDraw.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 "SkBBoxHierarchyRecord.h" 8 #include "SkBBoxHierarchyRecord.h"
9 #include "SkPictureRecord.h" 9 #include "SkPictureRecord.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 "SkTypes.h" 14 #include "SkTypes.h"
15 15
16 SkPictureRecorder::SkPictureRecorder() {} 16 SkPictureRecorder::SkPictureRecorder() {}
17 17
18 SkPictureRecorder::~SkPictureRecorder() {} 18 SkPictureRecorder::~SkPictureRecorder() {}
19 19
20 SkCanvas* SkPictureRecorder::beginRecording(int width, int height, 20 SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
21 SkBBHFactory* bbhFactory /* = NULL * /, 21 SkBBHFactory* bbhFactory /* = NULL * /,
22 uint32_t recordFlags /* = 0 */) { 22 uint32_t recordFlags /* = 0 */) {
23 fWidth = width; 23 fWidth = width;
24 fHeight = height; 24 fHeight = height;
25 25
26 const SkISize size = SkISize::Make(width, height); 26 const SkISize size = SkISize::Make(width, height);
27 27
28 if (NULL != bbhFactory) { 28 if (NULL != bbhFactory) {
29 SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height)); 29 // We don't need to hold a ref on the BBH ourselves, but might as well f or
30 SkASSERT(NULL != tree); 30 // consistency with EXPERIMENTAL_beginRecording(), which does need to.
31 fPictureRecord.reset(SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlag s, tree.get()))); 31 fBBH.reset((*bbhFactory)(width, height));
32 SkASSERT(NULL != fBBH.get());
33 fPictureRecord.reset(SkNEW_ARGS(SkBBoxHierarchyRecord, (size, recordFlag s, fBBH.get())));
32 } else { 34 } else {
33 fPictureRecord.reset(SkNEW_ARGS(SkPictureRecord, (size, recordFlags))); 35 fPictureRecord.reset(SkNEW_ARGS(SkPictureRecord, (size, recordFlags)));
34 } 36 }
35 37
36 fPictureRecord->beginRecording(); 38 fPictureRecord->beginRecording();
37 return this->getRecordingCanvas(); 39 return this->getRecordingCanvas();
38 } 40 }
39 41
40 SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(int width, int height, 42 SkCanvas* SkPictureRecorder::EXPERIMENTAL_beginRecording(int width, int height,
41 SkBBHFactory* bbhFactor y /* = NULL */) { 43 SkBBHFactory* bbhFactor y /* = NULL */) {
42 fWidth = width; 44 fWidth = width;
43 fHeight = height; 45 fHeight = height;
44 46
45 // TODO: plumb bbhFactory through 47 if (NULL != bbhFactory) {
48 fBBH.reset((*bbhFactory)(width, height));
49 SkASSERT(NULL != fBBH.get());
50 }
51
46 fRecord.reset(SkNEW(SkRecord)); 52 fRecord.reset(SkNEW(SkRecord));
47 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), width, height))); 53 fRecorder.reset(SkNEW_ARGS(SkRecorder, (fRecord.get(), width, height)));
48 return this->getRecordingCanvas(); 54 return this->getRecordingCanvas();
49 } 55 }
50 56
51 SkCanvas* SkPictureRecorder::getRecordingCanvas() { 57 SkCanvas* SkPictureRecorder::getRecordingCanvas() {
52 if (NULL != fRecorder.get()) { 58 if (NULL != fRecorder.get()) {
53 return fRecorder.get(); 59 return fRecorder.get();
54 } 60 }
55 return fPictureRecord.get(); 61 return fPictureRecord.get();
56 } 62 }
57 63
58 SkPicture* SkPictureRecorder::endRecording() { 64 SkPicture* SkPictureRecorder::endRecording() {
59 SkPicture* picture = NULL; 65 SkPicture* picture = NULL;
60 66
61 if (NULL != fRecord.get()) { 67 if (NULL != fRecord.get()) {
62 picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, fRecord.detach())); 68 picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, fRecord.detach(), fBBH .get()));
63 } 69 }
64 70
65 if (NULL != fPictureRecord.get()) { 71 if (NULL != fPictureRecord.get()) {
66 fPictureRecord->endRecording(); 72 fPictureRecord->endRecording();
67 const bool deepCopyOps = false; 73 const bool deepCopyOps = false;
68 picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, *fPictureRecord.get(), deepCopyOps)); 74 picture = SkNEW_ARGS(SkPicture, (fWidth, fHeight, *fPictureRecord.get(), deepCopyOps));
69 } 75 }
70 76
71 return picture; 77 return picture;
72 } 78 }
73 79
74 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) { 80 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
75 if (NULL != fPictureRecord.get()) { 81 if (NULL != fPictureRecord.get()) {
76 fPictureRecord->internalOnly_EnableOpts(enableOpts); 82 fPictureRecord->internalOnly_EnableOpts(enableOpts);
77 } 83 }
78 } 84 }
79 85
80 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 86 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
81 if (NULL == canvas) { 87 if (NULL == canvas) {
82 return; 88 return;
83 } 89 }
84 90
85 if (NULL != fRecord.get()) { 91 if (NULL != fRecord.get()) {
86 SkRecordDraw(*fRecord, canvas); 92 SkRecordDraw(*fRecord, canvas, NULL/*bbh*/, NULL/*callback*/);
87 } 93 }
88 94
89 if (NULL != fPictureRecord.get()) { 95 if (NULL != fPictureRecord.get()) {
90 const bool deepCopyOps = true; 96 const bool deepCopyOps = true;
91 SkPicture picture(fWidth, fHeight, *fPictureRecord.get(), deepCopyOps); 97 SkPicture picture(fWidth, fHeight, *fPictureRecord.get(), deepCopyOps);
92 picture.draw(canvas); 98 picture.draw(canvas);
93 } 99 }
94 } 100 }
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/core/SkRecordDraw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698