OLD | NEW |
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" |
11 | 11 |
12 #include "SkJSONCanvas.h" | |
13 | |
14 const int Request::kImageWidth = 1920; | 12 const int Request::kImageWidth = 1920; |
15 const int Request::kImageHeight = 1080; | 13 const int Request::kImageHeight = 1080; |
16 | 14 |
17 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l
ength) { | 15 static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t l
ength) { |
18 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); | 16 SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); |
19 out->write(data, length); | 17 out->write(data, length); |
20 } | 18 } |
21 | 19 |
22 static void write_png(const png_bytep rgba, png_uint_32 width, png_uint_32 heigh
t, SkWStream& out) { | 20 static void write_png(const png_bytep rgba, png_uint_32 width, png_uint_32 heigh
t, SkWStream& out) { |
23 png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL,
NULL); | 21 png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL,
NULL); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 SkAutoTUnref<SkSurface> surface(this->createCPUSurface()); | 219 SkAutoTUnref<SkSurface> surface(this->createCPUSurface()); |
222 SkCanvas* canvas = surface->getCanvas(); | 220 SkCanvas* canvas = surface->getCanvas(); |
223 | 221 |
224 // TODO this is really slow and we should cache the matrix and clip | 222 // TODO this is really slow and we should cache the matrix and clip |
225 fDebugCanvas->drawTo(canvas, n); | 223 fDebugCanvas->drawTo(canvas, n); |
226 | 224 |
227 // make some json | 225 // make some json |
228 SkMatrix vm = fDebugCanvas->getCurrentMatrix(); | 226 SkMatrix vm = fDebugCanvas->getCurrentMatrix(); |
229 SkIRect clip = fDebugCanvas->getCurrentClip(); | 227 SkIRect clip = fDebugCanvas->getCurrentClip(); |
230 Json::Value info(Json::objectValue); | 228 Json::Value info(Json::objectValue); |
231 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm); | 229 info["ViewMatrix"] = SkDrawCommand::MakeJsonMatrix(vm); |
232 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip); | 230 info["ClipRect"] = SkDrawCommand::MakeJsonIRect(clip); |
233 | 231 |
234 std::string json = Json::FastWriter().write(info); | 232 std::string json = Json::FastWriter().write(info); |
235 | 233 |
236 // We don't want the null terminator so strlen is correct | 234 // We don't want the null terminator so strlen is correct |
237 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str())); | 235 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str())); |
238 } | 236 } |
OLD | NEW |