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

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

Issue 318763004: First pass at splitting out SkPictureRecord from SkPicture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make dtor non-virtual Created 6 years, 6 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') | 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 // Need to include SkTypes first, so that SK_BUILD_FOR_ANDROID is defined. 8 #include "SkBBoxHierarchyRecord.h"
9 #include "SkTypes.h"
10 #ifdef SK_BUILD_FOR_ANDROID
11 #include "SkPicturePlayback.h" 9 #include "SkPicturePlayback.h"
12 #endif 10 #include "SkPictureRecord.h"
13 #include "SkPictureRecorder.h" 11 #include "SkPictureRecorder.h"
12 #include "SkTypes.h"
13
14 SkPictureRecorder::~SkPictureRecorder() {
15 SkSafeSetNull(fCanvas);
16 }
14 17
15 SkCanvas* SkPictureRecorder::beginRecording(int width, int height, 18 SkCanvas* SkPictureRecorder::beginRecording(int width, int height,
16 SkBBHFactory* bbhFactory /* = NULL * /, 19 SkBBHFactory* bbhFactory /* = NULL * /,
17 uint32_t recordFlags /* = 0 */) { 20 uint32_t recordFlags /* = 0 */) {
21 SkSafeSetNull(fCanvas);
18 fPicture.reset(SkNEW(SkPicture)); 22 fPicture.reset(SkNEW(SkPicture));
19 return fPicture->beginRecording(width, height, bbhFactory, recordFlags); 23
24 fPicture->fWidth = width;
25 fPicture->fHeight = height;
26
27 const SkISize size = SkISize::Make(width, height);
28
29 if (NULL != bbhFactory) {
30 SkAutoTUnref<SkBBoxHierarchy> tree((*bbhFactory)(width, height));
31 SkASSERT(NULL != tree);
32 fCanvas = SkNEW_ARGS(SkBBoxHierarchyRecord, (fPicture, size, recordFlags , tree.get()));
33 } else {
34 fCanvas = SkNEW_ARGS(SkPictureRecord, (fPicture, size, recordFlags));
35 }
36
37 fCanvas->beginRecording();
38
39 return fCanvas;
40 }
41
42 SkCanvas* SkPictureRecorder::getRecordingCanvas() {
43 return fCanvas;
44 }
45
46 SkPicture* SkPictureRecorder::endRecording() {
47 if (NULL == fPicture.get()) {
48 return NULL;
49 }
50
51 SkASSERT(NULL == fPicture->fPlayback);
52 SkASSERT(NULL != fCanvas);
53
54 fCanvas->endRecording();
55
56 SkPictInfo info;
57 fPicture->createHeader(&info);
58 fPicture->fPlayback = SkNEW_ARGS(SkPicturePlayback, (fPicture, *fCanvas, inf o));
59
60 SkSafeSetNull(fCanvas);
61
62 return fPicture.detach();
63 }
64
65 void SkPictureRecorder::internalOnly_EnableOpts(bool enableOpts) {
66 if (NULL != fCanvas) {
67 fCanvas->internalOnly_EnableOpts(enableOpts);
68 }
20 } 69 }
21 70
22 #ifdef SK_BUILD_FOR_ANDROID 71 #ifdef SK_BUILD_FOR_ANDROID
23 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 72 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
24 if (NULL == fPicture.get() || NULL == canvas) { 73 if (NULL == fPicture.get() || NULL == canvas) {
25 // Not recording or nothing to replay into 74 // Not recording or nothing to replay into
26 return; 75 return;
27 } 76 }
28 77
29 SkASSERT(NULL != fPicture->fRecord); 78 SkASSERT(NULL != fCanvas);
30 79
31 SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPictu re.get(), 80 SkAutoTDelete<SkPicturePlayback> playback(SkPicture::FakeEndRecording(fPictu re.get(),
32 *fPict ure->fRecord, 81 *fCanv as,
33 false) ); 82 false) );
34 playback->draw(*canvas, NULL); 83 playback->draw(*canvas, NULL);
35 } 84 }
36 #endif 85 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698