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

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

Issue 1750653002: Fixup some of the batch info in skiaserve (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: tweaks 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 | « no previous file | no next file » | 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // parse picture from stream 142 // parse picture from stream
143 fPicture.reset(SkPicture::CreateFromStream(stream)); 143 fPicture.reset(SkPicture::CreateFromStream(stream));
144 if (!fPicture.get()) { 144 if (!fPicture.get()) {
145 fprintf(stderr, "Could not create picture from stream.\n"); 145 fprintf(stderr, "Could not create picture from stream.\n");
146 return false; 146 return false;
147 } 147 }
148 148
149 // pour picture into debug canvas 149 // pour picture into debug canvas
150 fDebugCanvas.reset(new SkDebugCanvas(kImageWidth, Request::kImageHeight)); 150 fDebugCanvas.reset(new SkDebugCanvas(kImageWidth, Request::kImageHeight));
151 fDebugCanvas->drawPicture(fPicture); 151 fDebugCanvas->drawPicture(fPicture);
152
153 // for some reason we need to 'flush' the debug canvas by drawing all of the ops
154 fDebugCanvas->drawTo(this->getCanvas(), this->getLastOp());
152 return true; 155 return true;
153 } 156 }
154 157
155 GrAuditTrail* Request::getAuditTrail(SkCanvas* canvas) { 158 GrAuditTrail* Request::getAuditTrail(SkCanvas* canvas) {
156 GrAuditTrail* at = nullptr; 159 GrAuditTrail* at = nullptr;
157 #if SK_SUPPORT_GPU 160 #if SK_SUPPORT_GPU
158 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); 161 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
159 if (rt) { 162 if (rt) {
160 GrContext* ctx = rt->getContext(); 163 GrContext* ctx = rt->getContext();
161 if (ctx) { 164 if (ctx) {
(...skipping 25 matching lines...) Expand all
187 } 190 }
188 191
189 SkData* Request::getJsonBatchList(int n) { 192 SkData* Request::getJsonBatchList(int n) {
190 SkCanvas* canvas = this->getCanvas(); 193 SkCanvas* canvas = this->getCanvas();
191 SkASSERT(fGPUEnabled); 194 SkASSERT(fGPUEnabled);
192 195
193 // TODO if this is inefficient we could add a method to GrAuditTrail which t akes 196 // TODO if this is inefficient we could add a method to GrAuditTrail which t akes
194 // a Json::Value and is only compiled in this file 197 // a Json::Value and is only compiled in this file
195 Json::Value parsedFromString; 198 Json::Value parsedFromString;
196 #if SK_SUPPORT_GPU 199 #if SK_SUPPORT_GPU
200 // we use the toJSON method on debug canvas, but then just ignore the result s and pull
201 // the information we care about from the audit trail
202 fDebugCanvas->toJSON(fUrlDataManager, n, canvas);
203
197 GrAuditTrail* at = this->getAuditTrail(canvas); 204 GrAuditTrail* at = this->getAuditTrail(canvas);
198 GrAuditTrail::AutoManageBatchList enable(at); 205 GrAuditTrail::AutoManageBatchList enable(at);
199
200 fDebugCanvas->drawTo(canvas, n);
201
202 Json::Reader reader; 206 Json::Reader reader;
203 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(true).c_str(), 207 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson().c_str(),
204 parsedFromString); 208 parsedFromString);
205 SkASSERT(parsingSuccessful); 209 SkASSERT(parsingSuccessful);
206 #endif 210 #endif
207 211
208 SkDynamicMemoryWStream stream; 212 SkDynamicMemoryWStream stream;
209 stream.writeText(Json::FastWriter().write(parsedFromString).c_str()); 213 stream.writeText(Json::FastWriter().write(parsedFromString).c_str());
210 214
211 return stream.copyToData(); 215 return stream.copyToData();
212 } 216 }
213 217
(...skipping 10 matching lines...) Expand all
224 SkIRect clip = fDebugCanvas->getCurrentClip(); 228 SkIRect clip = fDebugCanvas->getCurrentClip();
225 Json::Value info(Json::objectValue); 229 Json::Value info(Json::objectValue);
226 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm); 230 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm);
227 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip); 231 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip);
228 232
229 std::string json = Json::FastWriter().write(info); 233 std::string json = Json::FastWriter().write(info);
230 234
231 // We don't want the null terminator so strlen is correct 235 // We don't want the null terminator so strlen is correct
232 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str())); 236 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str()));
233 } 237 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698