OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkDrawCommand.h" | 10 #include "SkDrawCommand.h" |
11 | |
12 #include "GrContext.h" | |
13 #include "GrRenderTarget.h" | |
14 | |
11 #include "SkBlurMaskFilter.h" | 15 #include "SkBlurMaskFilter.h" |
12 #include "SkColorFilter.h" | 16 #include "SkColorFilter.h" |
13 #include "SkDashPathEffect.h" | 17 #include "SkDashPathEffect.h" |
14 #include "SkImageFilter.h" | 18 #include "SkImageFilter.h" |
15 #include "SkMaskFilter.h" | 19 #include "SkMaskFilter.h" |
16 #include "SkObjectParser.h" | 20 #include "SkObjectParser.h" |
17 #include "SkPaintDefaults.h" | 21 #include "SkPaintDefaults.h" |
18 #include "SkPathEffect.h" | 22 #include "SkPathEffect.h" |
19 #include "SkPicture.h" | 23 #include "SkPicture.h" |
20 #include "SkTextBlob.h" | 24 #include "SkTextBlob.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 SkString SkDrawCommand::toString() const { | 215 SkString SkDrawCommand::toString() const { |
212 return SkString(GetCommandString(fOpType)); | 216 return SkString(GetCommandString(fOpType)); |
213 } | 217 } |
214 | 218 |
215 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const { | 219 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const { |
216 Json::Value result; | 220 Json::Value result; |
217 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); | 221 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); |
218 return result; | 222 return result; |
219 } | 223 } |
220 | 224 |
225 Json::Value SkDrawCommand::drawToAndCollectJSON(SkCanvas* canvas, | |
226 UrlDataManager& urlDataManager) const { | |
227 Json::Value result; | |
228 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); | |
229 | |
230 if (canvas) { | |
ethannicholas
2016/02/17 16:16:07
Why is the canvas to draw to optional in a method
joshualitt
2016/02/17 16:31:02
Acknowledged.
| |
231 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget (); | |
232 if (rt) { | |
233 GrContext* ctx = rt->getContext(); | |
234 if(ctx) { | |
235 this->execute(canvas); | |
236 GrAuditTrail* at = ctx->getAuditTrail(); | |
237 | |
238 // TODO if this is inefficient we could add a method to GrAuditT rail which takes | |
239 // a Json::Value and is only compiled in this file | |
240 Json::Value parsedFromString; | |
241 Json::Reader reader; | |
242 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(). c_str(), | |
243 parsedFromStr ing); | |
244 SkASSERT(parsingSuccessful); | |
245 | |
246 result["batches"] = parsedFromString; | |
ethannicholas
2016/02/17 16:16:07
Could we define a SKDEBUGCANVAS_ATTRIBUTE_BATCHES
joshualitt
2016/02/17 16:31:02
Acknowledged.
| |
247 at->reset(); | |
ethannicholas
2016/02/17 16:16:07
Resetting the auditor in between every single draw
joshualitt
2016/02/17 16:31:02
discussed offline
| |
248 } | |
249 } | |
250 } | |
251 return result; | |
252 } | |
253 | |
221 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \ | 254 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \ |
222 (FROM_JSON) Sk ## name ## Command::f romJSON) | 255 (FROM_JSON) Sk ## name ## Command::f romJSON) |
223 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) { | 256 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) { |
224 static SkTHashMap<SkString, FROM_JSON> factories; | 257 static SkTHashMap<SkString, FROM_JSON> factories; |
225 static bool initialized = false; | 258 static bool initialized = false; |
226 if (!initialized) { | 259 if (!initialized) { |
227 initialized = true; | 260 initialized = true; |
228 INSTALL_FACTORY(Restore); | 261 INSTALL_FACTORY(Restore); |
229 INSTALL_FACTORY(ClipPath); | 262 INSTALL_FACTORY(ClipPath); |
230 INSTALL_FACTORY(ClipRegion); | 263 INSTALL_FACTORY(ClipRegion); |
(...skipping 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3068 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); | 3101 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); |
3069 return result; | 3102 return result; |
3070 } | 3103 } |
3071 | 3104 |
3072 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3105 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
3073 UrlDataManager& urlDataManager) { | 3106 UrlDataManager& urlDataManager) { |
3074 SkMatrix matrix; | 3107 SkMatrix matrix; |
3075 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3108 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
3076 return new SkSetMatrixCommand(matrix); | 3109 return new SkSetMatrixCommand(matrix); |
3077 } | 3110 } |
OLD | NEW |