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

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

Issue 1745513002: Add abilitly to query audit trail for batches by draw op (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 | « tools/skiaserve/Request.h ('k') | 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 fGPUEnabled = true; 131 fGPUEnabled = true;
132 return true; 132 return true;
133 } 133 }
134 return false; 134 return false;
135 } 135 }
136 fSurface.reset(this->createCPUSurface()); 136 fSurface.reset(this->createCPUSurface());
137 fGPUEnabled = false; 137 fGPUEnabled = false;
138 return true; 138 return true;
139 } 139 }
140 140
141 GrAuditTrail* Request::getAuditTrail(SkCanvas* canvas) {
142 GrAuditTrail* at = nullptr;
143 #if SK_SUPPORT_GPU
144 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget();
145 if (rt) {
146 GrContext* ctx = rt->getContext();
147 if (ctx) {
148 at = ctx->getAuditTrail();
149 }
150 }
151 #endif
152 return at;
153 }
154
155 void Request::cleanupAuditTrail(SkCanvas* canvas) {
156 GrAuditTrail* at = this->getAuditTrail(canvas);
157 if (at) {
158 GrAuditTrail::AutoEnable ae(at);
159 at->fullReset();
160 }
161 }
162
141 SkData* Request::getJsonOps(int n) { 163 SkData* Request::getJsonOps(int n) {
142 SkCanvas* canvas = this->getCanvas(); 164 SkCanvas* canvas = this->getCanvas();
143 Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas); 165 Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas);
144 root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu"); 166 root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu");
145 SkDynamicMemoryWStream stream; 167 SkDynamicMemoryWStream stream;
146 stream.writeText(Json::FastWriter().write(root).c_str()); 168 stream.writeText(Json::FastWriter().write(root).c_str());
147 169
170 this->cleanupAuditTrail(canvas);
171
148 return stream.copyToData(); 172 return stream.copyToData();
149 } 173 }
150 174
151 SkData* Request::getJsonBatchList(int n) { 175 SkData* Request::getJsonBatchList(int n) {
152 SkCanvas* canvas = this->getCanvas(); 176 SkCanvas* canvas = this->getCanvas();
153 SkASSERT(fGPUEnabled); 177 SkASSERT(fGPUEnabled);
154 178
155 // TODO if this is inefficient we could add a method to GrAuditTrail which t akes 179 // TODO if this is inefficient we could add a method to GrAuditTrail which t akes
156 // a Json::Value and is only compiled in this file 180 // a Json::Value and is only compiled in this file
157 Json::Value parsedFromString; 181 Json::Value parsedFromString;
158 #if SK_SUPPORT_GPU 182 #if SK_SUPPORT_GPU
159 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget(); 183 GrAuditTrail* at = this->getAuditTrail(canvas);
160 SkASSERT(rt);
161 GrContext* ctx = rt->getContext();
162 SkASSERT(ctx);
163 GrAuditTrail* at = ctx->getAuditTrail();
164 GrAuditTrail::AutoManageBatchList enable(at); 184 GrAuditTrail::AutoManageBatchList enable(at);
165 185
166 fDebugCanvas->drawTo(canvas, n); 186 fDebugCanvas->drawTo(canvas, n);
167 187
168 Json::Reader reader; 188 Json::Reader reader;
169 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(true).c_str(), 189 SkDEBUGCODE(bool parsingSuccessful = )reader.parse(at->toJson(true).c_str(),
170 parsedFromString); 190 parsedFromString);
171 SkASSERT(parsingSuccessful); 191 SkASSERT(parsingSuccessful);
172 #endif 192 #endif
173 193
(...skipping 16 matching lines...) Expand all
190 SkIRect clip = fDebugCanvas->getCurrentClip(); 210 SkIRect clip = fDebugCanvas->getCurrentClip();
191 Json::Value info(Json::objectValue); 211 Json::Value info(Json::objectValue);
192 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm); 212 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm);
193 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip); 213 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip);
194 214
195 std::string json = Json::FastWriter().write(info); 215 std::string json = Json::FastWriter().write(info);
196 216
197 // We don't want the null terminator so strlen is correct 217 // We don't want the null terminator so strlen is correct
198 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str())); 218 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str()));
199 } 219 }
OLDNEW
« no previous file with comments | « tools/skiaserve/Request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698