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" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const { | 223 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const { |
224 Json::Value result; | 224 Json::Value result; |
225 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); | 225 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); |
226 result[SKDEBUGCANVAS_ATTRIBUTE_VISIBLE] = Json::Value(this->isVisible()); | 226 result[SKDEBUGCANVAS_ATTRIBUTE_VISIBLE] = Json::Value(this->isVisible()); |
227 return result; | 227 return result; |
228 } | 228 } |
229 | 229 |
230 Json::Value SkDrawCommand::drawToAndCollectJSON(SkCanvas* canvas, | 230 Json::Value SkDrawCommand::drawToAndCollectJSON(SkCanvas* canvas, |
231 UrlDataManager& urlDataManager)
const { | 231 UrlDataManager& urlDataManager, |
| 232 int opIndex) const { |
232 Json::Value result = this->toJSON(urlDataManager); | 233 Json::Value result = this->toJSON(urlDataManager); |
233 | 234 |
234 SkASSERT(canvas); | 235 SkASSERT(canvas); |
235 | 236 |
236 #if SK_SUPPORT_GPU | 237 #if SK_SUPPORT_GPU |
237 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); | 238 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); |
238 if (rt) { | 239 if (rt) { |
239 GrContext* ctx = rt->getContext(); | 240 GrContext* ctx = rt->getContext(); |
240 if(ctx) { | 241 if(ctx) { |
241 GrAuditTrail* at = ctx->getAuditTrail(); | 242 GrAuditTrail* at = ctx->getAuditTrail(); |
242 GrAuditTrail::AutoEnable enable(at); | 243 GrAuditTrail::AutoCollectBatches enable(at, opIndex); |
243 this->execute(canvas); | 244 this->execute(canvas); |
244 | 245 |
245 // TODO if this is inefficient we could add a method to GrAuditTrail
which takes | 246 // TODO if this is inefficient we could add a method to GrAuditTrail
which takes |
246 // a Json::Value and is only compiled in this file | 247 // a Json::Value and is only compiled in this file |
247 Json::Value parsedFromString; | 248 Json::Value parsedFromString; |
248 Json::Reader reader; | 249 Json::Reader reader; |
249 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson().c_st
r(), | 250 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(opInde
x).c_str(), |
250 parsedFromString)
; | 251 parsedFromString)
; |
251 SkASSERT(parsingSuccessful); | 252 SkASSERT(parsingSuccessful); |
252 | 253 |
253 result[SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString; | 254 result[SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString; |
254 at->reset(); | |
255 } | 255 } |
256 } | 256 } |
257 #endif | 257 #endif |
258 return result; | 258 return result; |
259 } | 259 } |
260 | 260 |
261 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name
##_OpType)), \ | 261 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name
##_OpType)), \ |
262 (FROM_JSON) Sk ## name ## Command::f
romJSON) | 262 (FROM_JSON) Sk ## name ## Command::f
romJSON) |
263 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url
DataManager) { | 263 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url
DataManager) { |
264 static SkTHashMap<SkString, FROM_JSON> factories; | 264 static SkTHashMap<SkString, FROM_JSON> factories; |
(...skipping 2843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3108 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); | 3108 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); |
3109 return result; | 3109 return result; |
3110 } | 3110 } |
3111 | 3111 |
3112 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, | 3112 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, |
3113 UrlDataManager& urlDataManager)
{ | 3113 UrlDataManager& urlDataManager)
{ |
3114 SkMatrix matrix; | 3114 SkMatrix matrix; |
3115 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); | 3115 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); |
3116 return new SkSetMatrixCommand(matrix); | 3116 return new SkSetMatrixCommand(matrix); |
3117 } | 3117 } |
OLD | NEW |