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

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

Issue 898343004: Rename SkCanvasDrawable to SkDrawable, and make public (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix gyp Created 5 years, 10 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/SkDrawable.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 "SkCanvasDrawable.h"
9 #include "SkData.h" 8 #include "SkData.h"
9 #include "SkDrawable.h"
10 #include "SkLayerInfo.h" 10 #include "SkLayerInfo.h"
11 #include "SkPictureRecorder.h" 11 #include "SkPictureRecorder.h"
12 #include "SkRecord.h" 12 #include "SkRecord.h"
13 #include "SkRecordDraw.h" 13 #include "SkRecordDraw.h"
14 #include "SkRecorder.h" 14 #include "SkRecorder.h"
15 #include "SkRecordOpts.h" 15 #include "SkRecordOpts.h"
16 #include "SkTypes.h" 16 #include "SkTypes.h"
17 17
18 SkPictureRecorder::SkPictureRecorder() {} 18 SkPictureRecorder::SkPictureRecorder() {}
19 19
(...skipping 24 matching lines...) Expand all
44 SkRecordOptimize(fRecord); 44 SkRecordOptimize(fRecord);
45 45
46 SkAutoTUnref<SkLayerInfo> saveLayerData; 46 SkAutoTUnref<SkLayerInfo> saveLayerData;
47 47
48 if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) { 48 if (fBBH && (fFlags & kComputeSaveLayerInfo_RecordFlag)) {
49 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey(); 49 SkPicture::AccelData::Key key = SkLayerInfo::ComputeKey();
50 50
51 saveLayerData.reset(SkNEW_ARGS(SkLayerInfo, (key))); 51 saveLayerData.reset(SkNEW_ARGS(SkLayerInfo, (key)));
52 } 52 }
53 53
54 SkCanvasDrawableList* drawableList = fRecorder->getDrawableList(); 54 SkDrawableList* drawableList = fRecorder->getDrawableList();
55 SkPicture::SnapshotArray* pictList = drawableList ? drawableList->newDrawabl eSnapshot() : NULL; 55 SkPicture::SnapshotArray* pictList = drawableList ? drawableList->newDrawabl eSnapshot() : NULL;
56 56
57 if (fBBH.get()) { 57 if (fBBH.get()) {
58 if (saveLayerData) { 58 if (saveLayerData) {
59 SkRecordComputeLayers(fCullRect, *fRecord, pictList, fBBH.get(), sav eLayerData); 59 SkRecordComputeLayers(fCullRect, *fRecord, pictList, fBBH.get(), sav eLayerData);
60 } else { 60 } else {
61 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); 61 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
62 } 62 }
63 } 63 }
64 64
(...skipping 10 matching lines...) Expand all
75 75
76 return pict; 76 return pict;
77 } 77 }
78 78
79 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const { 79 void SkPictureRecorder::partialReplay(SkCanvas* canvas) const {
80 if (NULL == canvas) { 80 if (NULL == canvas) {
81 return; 81 return;
82 } 82 }
83 83
84 int drawableCount = 0; 84 int drawableCount = 0;
85 SkCanvasDrawable* const* drawables = NULL; 85 SkDrawable* const* drawables = NULL;
86 SkCanvasDrawableList* drawableList = fRecorder->getDrawableList(); 86 SkDrawableList* drawableList = fRecorder->getDrawableList();
87 if (drawableList) { 87 if (drawableList) {
88 drawableCount = drawableList->count(); 88 drawableCount = drawableList->count();
89 drawables = drawableList->begin(); 89 drawables = drawableList->begin();
90 } 90 }
91 SkRecordDraw(*fRecord, canvas, NULL, drawables, drawableCount, NULL/*bbh*/, NULL/*callback*/); 91 SkRecordDraw(*fRecord, canvas, NULL, drawables, drawableCount, NULL/*bbh*/, NULL/*callback*/);
92 } 92 }
93 93
94 //////////////////////////////////////////////////////////////////////////////// /////////////////// 94 //////////////////////////////////////////////////////////////////////////////// ///////////////////
95 95
96 class SkRecordedDrawable : public SkCanvasDrawable { 96 class SkRecordedDrawable : public SkDrawable {
97 SkAutoTUnref<SkRecord> fRecord; 97 SkAutoTUnref<SkRecord> fRecord;
98 SkAutoTUnref<SkBBoxHierarchy> fBBH; 98 SkAutoTUnref<SkBBoxHierarchy> fBBH;
99 SkAutoTDelete<SkCanvasDrawableList> fDrawableList; 99 SkAutoTDelete<SkDrawableList> fDrawableList;
100 const SkRect fBounds; 100 const SkRect fBounds;
101 const bool fDoSaveLayerInfo; 101 const bool fDoSaveLayerInfo;
102 102
103 public: 103 public:
104 SkRecordedDrawable(SkRecord* record, SkBBoxHierarchy* bbh, SkCanvasDrawableL ist* drawableList, 104 SkRecordedDrawable(SkRecord* record, SkBBoxHierarchy* bbh, SkDrawableList* d rawableList,
105 const SkRect& bounds, bool doSaveLayerInfo) 105 const SkRect& bounds, bool doSaveLayerInfo)
106 : fRecord(SkRef(record)) 106 : fRecord(SkRef(record))
107 , fBBH(SkSafeRef(bbh)) 107 , fBBH(SkSafeRef(bbh))
108 , fDrawableList(drawableList) // we take ownership 108 , fDrawableList(drawableList) // we take ownership
109 , fBounds(bounds) 109 , fBounds(bounds)
110 , fDoSaveLayerInfo(doSaveLayerInfo) 110 , fDoSaveLayerInfo(doSaveLayerInfo)
111 {} 111 {}
112 112
113 protected: 113 protected:
114 SkRect onGetBounds() SK_OVERRIDE { return fBounds; } 114 SkRect onGetBounds() SK_OVERRIDE { return fBounds; }
115 115
116 void onDraw(SkCanvas* canvas) SK_OVERRIDE { 116 void onDraw(SkCanvas* canvas) SK_OVERRIDE {
117 SkCanvasDrawable* const* drawables = NULL; 117 SkDrawable* const* drawables = NULL;
118 int drawableCount = 0; 118 int drawableCount = 0;
119 if (fDrawableList) { 119 if (fDrawableList) {
120 drawables = fDrawableList->begin(); 120 drawables = fDrawableList->begin();
121 drawableCount = fDrawableList->count(); 121 drawableCount = fDrawableList->count();
122 } 122 }
123 SkRecordDraw(*fRecord, canvas, NULL, drawables, drawableCount, fBBH, NUL L/*callback*/); 123 SkRecordDraw(*fRecord, canvas, NULL, drawables, drawableCount, fBBH, NUL L/*callback*/);
124 } 124 }
125 125
126 SkPicture* onNewPictureSnapshot() SK_OVERRIDE { 126 SkPicture* onNewPictureSnapshot() SK_OVERRIDE {
127 SkPicture::SnapshotArray* pictList = NULL; 127 SkPicture::SnapshotArray* pictList = NULL;
(...skipping 18 matching lines...) Expand all
146 146
147 SkPicture* pict = SkNEW_ARGS(SkPicture, (fBounds, fRecord, pictList, fBB H)); 147 SkPicture* pict = SkNEW_ARGS(SkPicture, (fBounds, fRecord, pictList, fBB H));
148 148
149 if (saveLayerData) { 149 if (saveLayerData) {
150 pict->EXPERIMENTAL_addAccelData(saveLayerData); 150 pict->EXPERIMENTAL_addAccelData(saveLayerData);
151 } 151 }
152 return pict; 152 return pict;
153 } 153 }
154 }; 154 };
155 155
156 SkCanvasDrawable* SkPictureRecorder::EXPERIMENTAL_endRecordingAsDrawable() { 156 SkDrawable* SkPictureRecorder::endRecordingAsDrawable() {
157 // TODO: delay as much of this work until just before first playback? 157 // TODO: delay as much of this work until just before first playback?
158 SkRecordOptimize(fRecord); 158 SkRecordOptimize(fRecord);
159 159
160 if (fBBH.get()) { 160 if (fBBH.get()) {
161 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get()); 161 SkRecordFillBounds(fCullRect, *fRecord, fBBH.get());
162 } 162 }
163 163
164 SkCanvasDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable, 164 SkDrawable* drawable = SkNEW_ARGS(SkRecordedDrawable,
165 (fRecord, fBBH, fRecorder->detachDra wableList(), 165 (fRecord, fBBH, fRecorder->detachDrawabl eList(),
166 fCullRect, 166 fCullRect,
167 SkToBool(fFlags & kComputeSaveLayer Info_RecordFlag))); 167 SkToBool(fFlags & kComputeSaveLayerInfo _RecordFlag)));
168 168
169 // release our refs now, so only the drawable will be the owner. 169 // release our refs now, so only the drawable will be the owner.
170 fRecorder.reset(NULL); 170 fRecorder.reset(NULL);
171 fRecord.reset(NULL); 171 fRecord.reset(NULL);
172 fBBH.reset(NULL); 172 fBBH.reset(NULL);
173 173
174 return drawable; 174 return drawable;
175 } 175 }
OLDNEW
« no previous file with comments | « src/core/SkDrawable.cpp ('k') | src/core/SkRecordDraw.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698