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, | 231 UrlDataManager& urlDataManager)
const { |
232 int opIndex) const { | |
233 Json::Value result = this->toJSON(urlDataManager); | 232 Json::Value result = this->toJSON(urlDataManager); |
234 | 233 |
235 SkASSERT(canvas); | 234 SkASSERT(canvas); |
236 | 235 |
237 #if SK_SUPPORT_GPU | 236 #if SK_SUPPORT_GPU |
238 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); | 237 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); |
239 if (rt) { | 238 if (rt) { |
240 GrContext* ctx = rt->getContext(); | 239 GrContext* ctx = rt->getContext(); |
241 if(ctx) { | 240 if(ctx) { |
242 GrAuditTrail* at = ctx->getAuditTrail(); | 241 GrAuditTrail* at = ctx->getAuditTrail(); |
243 GrAuditTrail::AutoCollectBatches enable(at, opIndex); | 242 GrAuditTrail::AutoEnable enable(at); |
244 this->execute(canvas); | 243 this->execute(canvas); |
245 | 244 |
246 // TODO if this is inefficient we could add a method to GrAuditTrail
which takes | 245 // TODO if this is inefficient we could add a method to GrAuditTrail
which takes |
247 // a Json::Value and is only compiled in this file | 246 // a Json::Value and is only compiled in this file |
248 Json::Value parsedFromString; | 247 Json::Value parsedFromString; |
249 Json::Reader reader; | 248 Json::Reader reader; |
250 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(opInde
x).c_str(), | 249 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson().c_st
r(), |
251 parsedFromString)
; | 250 parsedFromString)
; |
252 SkASSERT(parsingSuccessful); | 251 SkASSERT(parsingSuccessful); |
253 | 252 |
254 result[SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString; | 253 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 |