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

Side by Side Diff: tools/debugger/SkDrawCommand.cpp

Issue 1705093002: Add batch information to json (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix cpu bot Created 4 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 | « tools/debugger/SkDrawCommand.h ('k') | tools/skiaserve/skiaserve.cpp » ('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 /* 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
11 #include "SkBlurMaskFilter.h" 12 #include "SkBlurMaskFilter.h"
12 #include "SkColorFilter.h" 13 #include "SkColorFilter.h"
13 #include "SkDashPathEffect.h" 14 #include "SkDashPathEffect.h"
14 #include "SkImageFilter.h" 15 #include "SkImageFilter.h"
15 #include "SkMaskFilter.h" 16 #include "SkMaskFilter.h"
16 #include "SkObjectParser.h" 17 #include "SkObjectParser.h"
17 #include "SkPaintDefaults.h" 18 #include "SkPaintDefaults.h"
18 #include "SkPathEffect.h" 19 #include "SkPathEffect.h"
19 #include "SkPicture.h" 20 #include "SkPicture.h"
20 #include "SkTextBlob.h" 21 #include "SkTextBlob.h"
21 #include "SkTextBlobRunIterator.h" 22 #include "SkTextBlobRunIterator.h"
22 #include "SkTHash.h" 23 #include "SkTHash.h"
23 #include "SkTypeface.h" 24 #include "SkTypeface.h"
24 #include "SkValidatingReadBuffer.h" 25 #include "SkValidatingReadBuffer.h"
25 #include "SkWriteBuffer.h" 26 #include "SkWriteBuffer.h"
26 27
28 #if SK_SUPPORT_GPU
29 #include "GrContext.h"
30 #include "GrRenderTarget.h"
31 #endif
32
27 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command" 33 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command"
34 #define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail"
28 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix" 35 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
29 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords" 36 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
30 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds" 37 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
31 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint" 38 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint"
32 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer" 39 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer"
33 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner" 40 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner"
34 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode" 41 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode"
35 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points" 42 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points"
36 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path" 43 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path"
37 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text" 44 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 SkString SkDrawCommand::toString() const { 218 SkString SkDrawCommand::toString() const {
212 return SkString(GetCommandString(fOpType)); 219 return SkString(GetCommandString(fOpType));
213 } 220 }
214 221
215 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const { 222 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const {
216 Json::Value result; 223 Json::Value result;
217 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); 224 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType);
218 return result; 225 return result;
219 } 226 }
220 227
228 Json::Value SkDrawCommand::drawToAndCollectJSON(SkCanvas* canvas,
229 UrlDataManager& urlDataManager) const {
230 Json::Value result;
231 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType);
232
233 SkASSERT(canvas);
234
235 #if SK_SUPPORT_GPU
236 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
237 if (rt) {
238 GrContext* ctx = rt->getContext();
239 if(ctx) {
240 this->execute(canvas);
241 GrAuditTrail* at = ctx->getAuditTrail();
242
243 // TODO if this is inefficient we could add a method to GrAuditTrail which takes
244 // a Json::Value and is only compiled in this file
245 Json::Value parsedFromString;
246 Json::Reader reader;
247 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson().c_st r(),
248 parsedFromString) ;
249 SkASSERT(parsingSuccessful);
250
251 result[SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString;
252 at->reset();
253 }
254 }
255 #endif
256 return result;
257 }
258
221 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \ 259 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \
222 (FROM_JSON) Sk ## name ## Command::f romJSON) 260 (FROM_JSON) Sk ## name ## Command::f romJSON)
223 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) { 261 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) {
224 static SkTHashMap<SkString, FROM_JSON> factories; 262 static SkTHashMap<SkString, FROM_JSON> factories;
225 static bool initialized = false; 263 static bool initialized = false;
226 if (!initialized) { 264 if (!initialized) {
227 initialized = true; 265 initialized = true;
228 INSTALL_FACTORY(Restore); 266 INSTALL_FACTORY(Restore);
229 INSTALL_FACTORY(ClipPath); 267 INSTALL_FACTORY(ClipPath);
230 INSTALL_FACTORY(ClipRegion); 268 INSTALL_FACTORY(ClipRegion);
(...skipping 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix); 3106 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = make_json_matrix(fMatrix);
3069 return result; 3107 return result;
3070 } 3108 }
3071 3109
3072 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, 3110 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3073 UrlDataManager& urlDataManager) { 3111 UrlDataManager& urlDataManager) {
3074 SkMatrix matrix; 3112 SkMatrix matrix;
3075 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3113 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3076 return new SkSetMatrixCommand(matrix); 3114 return new SkSetMatrixCommand(matrix);
3077 } 3115 }
OLDNEW
« no previous file with comments | « tools/debugger/SkDrawCommand.h ('k') | tools/skiaserve/skiaserve.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698