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

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

Issue 1741043003: A bit more privacy for SkiaServe's Request (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: 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') | tools/skiaserve/urlhandlers/BreakHandler.cpp » ('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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (surface) { 129 if (surface) {
130 fSurface.reset(surface); 130 fSurface.reset(surface);
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 }
140
141 bool Request::initPictureFromStream(SkStream* stream) {
142 // parse picture from stream
143 fPicture.reset(SkPicture::CreateFromStream(stream));
144 if (!fPicture.get()) {
145 fprintf(stderr, "Could not create picture from stream.\n");
146 return false;
147 }
148
149 // pour picture into debug canvas
150 fDebugCanvas.reset(new SkDebugCanvas(kImageWidth, Request::kImageHeight));
151 fDebugCanvas->drawPicture(fPicture);
152 return true;
139 } 153 }
140 154
141 SkData* Request::getJsonOps(int n) { 155 SkData* Request::getJsonOps(int n) {
142 SkCanvas* canvas = this->getCanvas(); 156 SkCanvas* canvas = this->getCanvas();
143 Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas); 157 Json::Value root = fDebugCanvas->toJSON(fUrlDataManager, n, canvas);
144 root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu"); 158 root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu");
145 SkDynamicMemoryWStream stream; 159 SkDynamicMemoryWStream stream;
146 stream.writeText(Json::FastWriter().write(root).c_str()); 160 stream.writeText(Json::FastWriter().write(root).c_str());
147 161
148 return stream.copyToData(); 162 return stream.copyToData();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 SkIRect clip = fDebugCanvas->getCurrentClip(); 204 SkIRect clip = fDebugCanvas->getCurrentClip();
191 Json::Value info(Json::objectValue); 205 Json::Value info(Json::objectValue);
192 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm); 206 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm);
193 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip); 207 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip);
194 208
195 std::string json = Json::FastWriter().write(info); 209 std::string json = Json::FastWriter().write(info);
196 210
197 // We don't want the null terminator so strlen is correct 211 // We don't want the null terminator so strlen is correct
198 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str())); 212 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str()));
199 } 213 }
OLDNEW
« no previous file with comments | « tools/skiaserve/Request.h ('k') | tools/skiaserve/urlhandlers/BreakHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698