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

Side by Side Diff: tools/skiaserve/skiaserve.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.cpp ('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 "GrCaps.h" 8 #include "GrCaps.h"
9 #include "GrContextFactory.h" 9 #include "GrContextFactory.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 fprintf(stderr, "Can't read pixels\n"); 129 fprintf(stderr, "Can't read pixels\n");
130 return nullptr; 130 return nullptr;
131 } 131 }
132 132
133 // write to png 133 // write to png
134 SkDynamicMemoryWStream buffer; 134 SkDynamicMemoryWStream buffer;
135 write_png((const png_bytep) bmp.getPixels(), bmp.width(), bmp.height(), buff er); 135 write_png((const png_bytep) bmp.getPixels(), bmp.width(), bmp.height(), buff er);
136 return buffer.copyToData(); 136 return buffer.copyToData();
137 } 137 }
138 138
139 SkData* setupAndDrawToCanvasReturnPng(Request* request, int n) { 139 SkCanvas* getCanvasFromRequest(Request* request) {
140 GrContextFactory* factory = request->fContextFactory; 140 GrContextFactory* factory = request->fContextFactory;
141 SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContex tType, 141 SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContex tType,
142 GrContextFactory::kNone_GLContextO ptions).fGLContext; 142 GrContextFactory::kNone_GLContextO ptions).fGLContext;
143 gl->makeCurrent(); 143 gl->makeCurrent();
144 SkASSERT(request->fDebugCanvas); 144 SkASSERT(request->fDebugCanvas);
145 SkCanvas* target = request->fSurface->getCanvas(); 145 SkCanvas* target = request->fSurface->getCanvas();
146 return target;
147 }
148
149 SkData* setupAndDrawToCanvasReturnPng(Request* request, int n) {
150 SkCanvas* target = getCanvasFromRequest(request);
146 request->fDebugCanvas->drawTo(target, n); 151 request->fDebugCanvas->drawTo(target, n);
147 return writeCanvasToPng(target); 152 return writeCanvasToPng(target);
148 } 153 }
149 154
150 SkSurface* setupCpuSurface() { 155 SkSurface* setupCpuSurface() {
151 SkImageInfo info = SkImageInfo::Make(kImageWidth, kImageHeight, kN32_SkColor Type, 156 SkImageInfo info = SkImageInfo::Make(kImageWidth, kImageHeight, kN32_SkColor Type,
152 kPremul_SkAlphaType); 157 kPremul_SkAlphaType);
153 return SkSurface::NewRaster(info); 158 return SkSurface::NewRaster(info);
154 } 159 }
155 160
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 193
189 if (setContentDisposition) { 194 if (setContentDisposition) {
190 MHD_add_response_header(response, "Content-Disposition", dispositionStri ng); 195 MHD_add_response_header(response, "Content-Disposition", dispositionStri ng);
191 } 196 }
192 197
193 int ret = MHD_queue_response(connection, MHD_HTTP_OK, response); 198 int ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
194 MHD_destroy_response(response); 199 MHD_destroy_response(response);
195 return ret; 200 return ret;
196 } 201 }
197 202
198 static int SendJSON(MHD_Connection* connection, SkDebugCanvas* debugCanvas, 203 static int SendJSON(MHD_Connection* connection, SkCanvas* canvas, SkDebugCanvas* debugCanvas,
199 UrlDataManager* urlDataManager, int n) { 204 UrlDataManager* urlDataManager, int n) {
200 Json::Value root = debugCanvas->toJSON(*urlDataManager, n); 205 Json::Value root = debugCanvas->toJSON(*urlDataManager, n, canvas);
201 SkDynamicMemoryWStream stream; 206 SkDynamicMemoryWStream stream;
202 stream.writeText(Json::FastWriter().write(root).c_str()); 207 stream.writeText(Json::FastWriter().write(root).c_str());
203 208
204 SkAutoTUnref<SkData> data(stream.copyToData()); 209 SkAutoTUnref<SkData> data(stream.copyToData());
205 return SendData(connection, data, "application/json"); 210 return SendData(connection, data, "application/json");
206 } 211 }
207 212
208 static int SendTemplate(MHD_Connection* connection, bool redirect = false, 213 static int SendTemplate(MHD_Connection* connection, bool redirect = false,
209 const char* redirectUrl = nullptr) { 214 const char* redirectUrl = nullptr) {
210 SkString debuggerTemplate = generateTemplate(SkString(FLAGS_source[0])); 215 SkString debuggerTemplate = generateTemplate(SkString(FLAGS_source[0]));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 259 }
255 260
256 // /cmd or /cmd/N 261 // /cmd or /cmd/N
257 if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) { 262 if (0 == strcmp(method, MHD_HTTP_METHOD_GET)) {
258 int n; 263 int n;
259 if (commands.count() == 1) { 264 if (commands.count() == 1) {
260 n = request->fDebugCanvas->getSize() - 1; 265 n = request->fDebugCanvas->getSize() - 1;
261 } else { 266 } else {
262 sscanf(commands[1].c_str(), "%d", &n); 267 sscanf(commands[1].c_str(), "%d", &n);
263 } 268 }
264 return SendJSON(connection, request->fDebugCanvas, &request->fUrlDat aManager, n); 269 return SendJSON(connection, getCanvasFromRequest(request), request-> fDebugCanvas,
270 &request->fUrlDataManager, n);
265 } 271 }
266 272
267 // /cmd/N, for now only delete supported 273 // /cmd/N, for now only delete supported
268 if (commands.count() == 2 && 0 == strcmp(method, MHD_HTTP_METHOD_DELETE) ) { 274 if (commands.count() == 2 && 0 == strcmp(method, MHD_HTTP_METHOD_DELETE) ) {
269 int n; 275 int n;
270 sscanf(commands[1].c_str(), "%d", &n); 276 sscanf(commands[1].c_str(), "%d", &n);
271 request->fDebugCanvas->deleteDrawCommandAt(n); 277 request->fDebugCanvas->deleteDrawCommandAt(n);
272 return SendOK(connection); 278 return SendOK(connection);
273 } 279 }
274 280
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 MHD_stop_daemon(daemon); 629 MHD_stop_daemon(daemon);
624 return 0; 630 return 0;
625 } 631 }
626 632
627 #if !defined SK_BUILD_FOR_IOS 633 #if !defined SK_BUILD_FOR_IOS
628 int main(int argc, char** argv) { 634 int main(int argc, char** argv) {
629 SkCommandLineFlags::Parse(argc, argv); 635 SkCommandLineFlags::Parse(argc, argv);
630 return skiaserve_main(); 636 return skiaserve_main();
631 } 637 }
632 #endif 638 #endif
OLDNEW
« no previous file with comments | « tools/debugger/SkDrawCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698