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

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

Issue 1761003004: Fix SkiaServe gpu JSON to work with any reordering algorithm (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: feedback inc Created 4 years, 9 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
12 #include "SkBlurMaskFilter.h" 12 #include "SkBlurMaskFilter.h"
13 #include "SkColorFilter.h" 13 #include "SkColorFilter.h"
14 #include "SkDashPathEffect.h" 14 #include "SkDashPathEffect.h"
15 #include "SkImageFilter.h" 15 #include "SkImageFilter.h"
16 #include "SkMaskFilter.h" 16 #include "SkMaskFilter.h"
17 #include "SkObjectParser.h" 17 #include "SkObjectParser.h"
18 #include "SkPaintDefaults.h" 18 #include "SkPaintDefaults.h"
19 #include "SkPathEffect.h" 19 #include "SkPathEffect.h"
20 #include "SkPicture.h" 20 #include "SkPicture.h"
21 #include "SkTextBlob.h" 21 #include "SkTextBlob.h"
22 #include "SkTextBlobRunIterator.h" 22 #include "SkTextBlobRunIterator.h"
23 #include "SkTHash.h" 23 #include "SkTHash.h"
24 #include "SkTypeface.h" 24 #include "SkTypeface.h"
25 #include "SkValidatingReadBuffer.h" 25 #include "SkValidatingReadBuffer.h"
26 #include "SkWriteBuffer.h" 26 #include "SkWriteBuffer.h"
27 27
28 #if SK_SUPPORT_GPU
29 #include "GrContext.h"
30 #include "GrRenderTarget.h"
31 #endif
32
33 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command" 28 #define SKDEBUGCANVAS_ATTRIBUTE_COMMAND "command"
34 #define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible" 29 #define SKDEBUGCANVAS_ATTRIBUTE_VISIBLE "visible"
35 #define SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL "auditTrail"
36 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix" 30 #define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
37 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords" 31 #define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
38 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds" 32 #define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
39 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint" 33 #define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint"
40 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer" 34 #define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer"
41 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner" 35 #define SKDEBUGCANVAS_ATTRIBUTE_INNER "inner"
42 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode" 36 #define SKDEBUGCANVAS_ATTRIBUTE_MODE "mode"
43 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points" 37 #define SKDEBUGCANVAS_ATTRIBUTE_POINTS "points"
44 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path" 38 #define SKDEBUGCANVAS_ATTRIBUTE_PATH "path"
45 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text" 39 #define SKDEBUGCANVAS_ATTRIBUTE_TEXT "text"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return SkString(GetCommandString(fOpType)); 214 return SkString(GetCommandString(fOpType));
221 } 215 }
222 216
223 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const { 217 Json::Value SkDrawCommand::toJSON(UrlDataManager& urlDataManager) const {
224 Json::Value result; 218 Json::Value result;
225 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType); 219 result[SKDEBUGCANVAS_ATTRIBUTE_COMMAND] = this->GetCommandString(fOpType);
226 result[SKDEBUGCANVAS_ATTRIBUTE_VISIBLE] = Json::Value(this->isVisible()); 220 result[SKDEBUGCANVAS_ATTRIBUTE_VISIBLE] = Json::Value(this->isVisible());
227 return result; 221 return result;
228 } 222 }
229 223
230 Json::Value SkDrawCommand::drawToAndCollectJSON(SkCanvas* canvas,
231 UrlDataManager& urlDataManager,
232 int opIndex) const {
233 Json::Value result = this->toJSON(urlDataManager);
234
235 SkASSERT(canvas);
236
237 #if SK_SUPPORT_GPU
238 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
239 if (rt) {
240 GrContext* ctx = rt->getContext();
241 if(ctx) {
242 GrAuditTrail* at = ctx->getAuditTrail();
243 GrAuditTrail::AutoCollectBatches enable(at, opIndex);
244 this->execute(canvas);
245
246 // 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
248 Json::Value parsedFromString;
249 Json::Reader reader;
250 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(opInde x).c_str(),
251 parsedFromString) ;
252 SkASSERT(parsingSuccessful);
253
254 result[SKDEBUGCANVAS_ATTRIBUTE_AUDITTRAIL] = parsedFromString;
255 }
256 }
257 #endif
258 return result;
259 }
260
261 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \ 224 #define INSTALL_FACTORY(name) factories.set(SkString(GetCommandString(k ## name ##_OpType)), \
262 (FROM_JSON) Sk ## name ## Command::f romJSON) 225 (FROM_JSON) Sk ## name ## Command::f romJSON)
263 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) { 226 SkDrawCommand* SkDrawCommand::fromJSON(Json::Value& command, UrlDataManager& url DataManager) {
264 static SkTHashMap<SkString, FROM_JSON> factories; 227 static SkTHashMap<SkString, FROM_JSON> factories;
265 static bool initialized = false; 228 static bool initialized = false;
266 if (!initialized) { 229 if (!initialized) {
267 initialized = true; 230 initialized = true;
268 INSTALL_FACTORY(Restore); 231 INSTALL_FACTORY(Restore);
269 INSTALL_FACTORY(ClipPath); 232 INSTALL_FACTORY(ClipPath);
270 INSTALL_FACTORY(ClipRegion); 233 INSTALL_FACTORY(ClipRegion);
(...skipping 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix); 3071 result[SKDEBUGCANVAS_ATTRIBUTE_MATRIX] = MakeJsonMatrix(fMatrix);
3109 return result; 3072 return result;
3110 } 3073 }
3111 3074
3112 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command, 3075 SkSetMatrixCommand* SkSetMatrixCommand::fromJSON(Json::Value& command,
3113 UrlDataManager& urlDataManager) { 3076 UrlDataManager& urlDataManager) {
3114 SkMatrix matrix; 3077 SkMatrix matrix;
3115 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix); 3078 extract_json_matrix(command[SKDEBUGCANVAS_ATTRIBUTE_MATRIX], &matrix);
3116 return new SkSetMatrixCommand(matrix); 3079 return new SkSetMatrixCommand(matrix);
3117 } 3080 }
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