| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "gm.h" | 7 #include "gm.h" |
| 8 #include "Resources.h" | 8 #include "Resources.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 canvas->translate(-px, -py); | 41 canvas->translate(-px, -py); |
| 42 } | 42 } |
| 43 | 43 |
| 44 virtual void onDraw(SkCanvas* inputCanvas) override { | 44 virtual void onDraw(SkCanvas* inputCanvas) override { |
| 45 SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f }; | 45 SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f }; |
| 46 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f }; | 46 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f }; |
| 47 | 47 |
| 48 // set up offscreen rendering with distance field text | 48 // set up offscreen rendering with distance field text |
| 49 #if SK_SUPPORT_GPU | 49 #if SK_SUPPORT_GPU |
| 50 GrContext* ctx = inputCanvas->getGrContext(); | 50 GrContext* ctx = inputCanvas->getGrContext(); |
| 51 SkISize size = onISize(); | 51 SkImageInfo info = SkImageInfo::MakeN32Premul(onISize(), |
| 52 SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPr
emul_SkAlphaType, | 52 inputCanvas->imageInfo().p
rofileType()); |
| 53 sk_ref_sp(inputCanvas->imageInfo
().colorSpace())); | |
| 54 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); | 53 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); |
| 55 uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps) | 54 uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps) |
| 56 ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0; | 55 ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0; |
| 57 SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | g
ammaCorrect, | 56 SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | g
ammaCorrect, |
| 58 SkSurfaceProps::kLegacyFontHost_InitType); | 57 SkSurfaceProps::kLegacyFontHost_InitType); |
| 59 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
&props)); | 58 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
&props)); |
| 60 SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas; | 59 SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas; |
| 61 // init our new canvas with the old canvas's matrix | 60 // init our new canvas with the old canvas's matrix |
| 62 canvas->setMatrix(inputCanvas->getTotalMatrix()); | 61 canvas->setMatrix(inputCanvas->getTotalMatrix()); |
| 63 #else | 62 #else |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 210 } |
| 212 | 211 |
| 213 private: | 212 private: |
| 214 sk_sp<SkTypeface> fEmojiTypeface; | 213 sk_sp<SkTypeface> fEmojiTypeface; |
| 215 const char* fEmojiText; | 214 const char* fEmojiText; |
| 216 | 215 |
| 217 typedef skiagm::GM INHERITED; | 216 typedef skiagm::GM INHERITED; |
| 218 }; | 217 }; |
| 219 | 218 |
| 220 DEF_GM(return new DFTextGM;) | 219 DEF_GM(return new DFTextGM;) |
| OLD | NEW |