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

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

Issue 1738483003: Move Request to its own file in preparation for numerous cleanups (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: merge 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') | 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
11 #include "Request.h"
12
10 #include "SkCanvas.h" 13 #include "SkCanvas.h"
11 #include "SkCommandLineFlags.h" 14 #include "SkCommandLineFlags.h"
12 #include "SkDebugCanvas.h"
13 #include "SkJSONCanvas.h" 15 #include "SkJSONCanvas.h"
14 #include "SkJSONCPP.h"
15 #include "SkPicture.h"
16 #include "SkPictureRecorder.h" 16 #include "SkPictureRecorder.h"
17 #include "SkPixelSerializer.h" 17 #include "SkPixelSerializer.h"
18 #include "SkStream.h"
19 #include "SkSurface.h"
20
21 #include "UrlDataManager.h"
22 18
23 #include <sys/socket.h> 19 #include <sys/socket.h>
24 #include <microhttpd.h> 20 #include <microhttpd.h>
25 #include "png.h" 21 #include "png.h"
26 22
27 // To get image decoders linked in we have to do the below magic 23 // To get image decoders linked in we have to do the below magic
28 #include "SkForceLinking.h" 24 #include "SkForceLinking.h"
29 #include "SkImageDecoder.h" 25 #include "SkImageDecoder.h"
30 __SK_FORCE_IMAGE_DECODER_LINKING; 26 __SK_FORCE_IMAGE_DECODER_LINKING;
31 27
(...skipping 20 matching lines...) Expand all
52 "</head>\n" 48 "</head>\n"
53 "<body class=\"fullbleed layout vertical\">\n" 49 "<body class=\"fullbleed layout vertical\">\n"
54 " <debugger-app-sk>This is the app." 50 " <debugger-app-sk>This is the app."
55 " </debugger-app-sk>\n" 51 " </debugger-app-sk>\n"
56 "</body>\n" 52 "</body>\n"
57 "</html>", source.c_str(), source.c_str()); 53 "</html>", source.c_str(), source.c_str());
58 return debuggerTemplate; 54 return debuggerTemplate;
59 55
60 } 56 }
61 57
62 struct UploadContext {
63 SkDynamicMemoryWStream fStream;
64 MHD_PostProcessor* fPostProcessor;
65 MHD_Connection* connection;
66 };
67
68 struct Request {
69 Request(SkString rootUrl)
70 : fUploadContext(nullptr)
71 , fUrlDataManager(rootUrl)
72 , fGPUEnabled(false) {}
73
74 UploadContext* fUploadContext;
75 SkAutoTUnref<SkPicture> fPicture;
76 SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
77 SkAutoTDelete<GrContextFactory> fContextFactory;
78 SkAutoTUnref<SkSurface> fSurface;
79 UrlDataManager fUrlDataManager;
80 bool fGPUEnabled;
81 };
82
83 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l ength) { 58 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l ength) {
84 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); 59 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr);
85 out->write(data, length); 60 out->write(data, length);
86 } 61 }
87 62
88 static void write_png(const png_bytep rgba, png_uint_32 width, png_uint_32 heigh t, SkWStream& out) { 63 static void write_png(const png_bytep rgba, png_uint_32 width, png_uint_32 heigh t, SkWStream& out) {
89 png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 64 png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
90 SkASSERT(png != nullptr); 65 SkASSERT(png != nullptr);
91 png_infop info_ptr = png_create_info_struct(png); 66 png_infop info_ptr = png_create_info_struct(png);
92 SkASSERT(info_ptr != nullptr); 67 SkASSERT(info_ptr != nullptr);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 MHD_stop_daemon(daemon); 742 MHD_stop_daemon(daemon);
768 return 0; 743 return 0;
769 } 744 }
770 745
771 #if !defined SK_BUILD_FOR_IOS 746 #if !defined SK_BUILD_FOR_IOS
772 int main(int argc, char** argv) { 747 int main(int argc, char** argv) {
773 SkCommandLineFlags::Parse(argc, argv); 748 SkCommandLineFlags::Parse(argc, argv);
774 return skiaserve_main(); 749 return skiaserve_main();
775 } 750 }
776 #endif 751 #endif
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