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

Side by Side Diff: tools/skiaserve/Request.cpp

Issue 1737323002: Wire up /batches in skiaserve (Closed) Base URL: https://skia.googlesource.com/skia@skiaserve-1
Patch Set: minor tweak 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/skiaserve/Request.h ('k') | tools/skiaserve/Response.h » ('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 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Request.h" 8 #include "Request.h"
9 9
10 #include "png.h" 10 #include "png.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 SkImageInfo info = SkImageInfo::Make(SkTMin(kImageWidth, maxRTSize), 104 SkImageInfo info = SkImageInfo::Make(SkTMin(kImageWidth, maxRTSize),
105 SkTMin(kImageHeight, maxRTSize), 105 SkTMin(kImageHeight, maxRTSize),
106 kN32_SkColorType, kPremul_SkAlphaType); 106 kN32_SkColorType, kPremul_SkAlphaType);
107 uint32_t flags = 0; 107 uint32_t flags = 0;
108 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType); 108 SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
109 SkSurface* surface = SkSurface::NewRenderTarget(context, SkBudgeted::kNo, in fo, 0, 109 SkSurface* surface = SkSurface::NewRenderTarget(context, SkBudgeted::kNo, in fo, 0,
110 &props); 110 &props);
111 return surface; 111 return surface;
112 } 112 }
113 113
114 SkData* Request::getJsonOps(int n) {
115 SkCanvas* canvas = this->getCanvas();
116 Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas);
117 root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu");
118 SkDynamicMemoryWStream stream;
119 stream.writeText(Json::FastWriter().write(root).c_str());
120
121 return stream.copyToData();
122 }
123
124 SkData* Request::getJsonBatchList(int n) {
125 SkCanvas* canvas = this->getCanvas();
126 SkASSERT(fGPUEnabled);
127
128 // TODO if this is inefficient we could add a method to GrAuditTrail which t akes
129 // a Json::Value and is only compiled in this file
130 Json::Value parsedFromString;
131 #if SK_SUPPORT_GPU
132 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
133 SkASSERT(rt);
134 GrContext* ctx = rt->getContext();
135 SkASSERT(ctx);
136 GrAuditTrail* at = ctx->getAuditTrail();
137 GrAuditTrail::AutoManageBatchList enable(at);
138
139 fDebugCanvas->drawTo(canvas, n);
140
141 Json::Reader reader;
142 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(true).c_str(),
143 parsedFromString);
144 SkASSERT(parsingSuccessful);
145 #endif
146
147 SkDynamicMemoryWStream stream;
148 stream.writeText(Json::FastWriter().write(parsedFromString).c_str());
149
150 return stream.copyToData();
151 }
OLDNEW
« no previous file with comments | « tools/skiaserve/Request.h ('k') | tools/skiaserve/Response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698