| 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" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 SkCanvas* Request::getCanvas() { | 86 SkCanvas* Request::getCanvas() { |
| 87 GrContextFactory* factory = fContextFactory; | 87 GrContextFactory* factory = fContextFactory; |
| 88 SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContex
tType, | 88 SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContex
tType, |
| 89 GrContextFactory::kNone_GLContextO
ptions).fGLContext; | 89 GrContextFactory::kNone_GLContextO
ptions).fGLContext; |
| 90 gl->makeCurrent(); | 90 gl->makeCurrent(); |
| 91 SkASSERT(fDebugCanvas); | 91 SkASSERT(fDebugCanvas); |
| 92 SkCanvas* target = fSurface->getCanvas(); | 92 SkCanvas* target = fSurface->getCanvas(); |
| 93 return target; | 93 return target; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void Request::drawToCanvas(int n) { | 96 void Request::drawToCanvas(int n, int m) { |
| 97 SkCanvas* target = this->getCanvas(); | 97 SkCanvas* target = this->getCanvas(); |
| 98 fDebugCanvas->drawTo(target, n); | 98 fDebugCanvas->drawTo(target, n, m); |
| 99 } | 99 } |
| 100 | 100 |
| 101 SkData* Request::drawToPng(int n) { | 101 SkData* Request::drawToPng(int n, int m) { |
| 102 this->drawToCanvas(n); | 102 this->drawToCanvas(n, m); |
| 103 return writeCanvasToPng(this->getCanvas()); | 103 return writeCanvasToPng(this->getCanvas()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 SkSurface* Request::createCPUSurface() { | 106 SkSurface* Request::createCPUSurface() { |
| 107 SkImageInfo info = SkImageInfo::Make(kImageWidth, kImageHeight, kN32_SkColor
Type, | 107 SkImageInfo info = SkImageInfo::Make(kImageWidth, kImageHeight, kN32_SkColor
Type, |
| 108 kPremul_SkAlphaType); | 108 kPremul_SkAlphaType); |
| 109 return SkSurface::NewRaster(info); | 109 return SkSurface::NewRaster(info); |
| 110 } | 110 } |
| 111 | 111 |
| 112 SkSurface* Request::createGPUSurface() { | 112 SkSurface* Request::createGPUSurface() { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 SkIRect clip = fDebugCanvas->getCurrentClip(); | 229 SkIRect clip = fDebugCanvas->getCurrentClip(); |
| 230 Json::Value info(Json::objectValue); | 230 Json::Value info(Json::objectValue); |
| 231 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm); | 231 info["ViewMatrix"] = SkJSONCanvas::MakeMatrix(vm); |
| 232 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip); | 232 info["ClipRect"] = SkJSONCanvas::MakeIRect(clip); |
| 233 | 233 |
| 234 std::string json = Json::FastWriter().write(info); | 234 std::string json = Json::FastWriter().write(info); |
| 235 | 235 |
| 236 // We don't want the null terminator so strlen is correct | 236 // We don't want the null terminator so strlen is correct |
| 237 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str())); | 237 return SkData::NewWithCopy(json.c_str(), strlen(json.c_str())); |
| 238 } | 238 } |
| OLD | NEW |