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 25 matching lines...) Expand all Loading... |
36 virtual void onDraw(SkCanvas* inputCanvas) override { | 36 virtual void onDraw(SkCanvas* inputCanvas) override { |
37 SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f }; | 37 SkScalar textSizes[] = { 9.0f, 9.0f*2.0f, 9.0f*5.0f, 9.0f*2.0f*5.0f }; |
38 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f }; | 38 SkScalar scales[] = { 2.0f*5.0f, 5.0f, 2.0f, 1.0f }; |
39 | 39 |
40 // set up offscreen rendering with distance field text | 40 // set up offscreen rendering with distance field text |
41 #if SK_SUPPORT_GPU | 41 #if SK_SUPPORT_GPU |
42 GrContext* ctx = inputCanvas->getGrContext(); | 42 GrContext* ctx = inputCanvas->getGrContext(); |
43 SkISize size = onISize(); | 43 SkISize size = onISize(); |
44 SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPr
emul_SkAlphaType, | 44 SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPr
emul_SkAlphaType, |
45 sk_ref_sp(inputCanvas->imageInfo
().colorSpace())); | 45 sk_ref_sp(inputCanvas->imageInfo
().colorSpace())); |
46 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); | 46 SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag, |
47 uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps) | |
48 ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0; | |
49 SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | g
ammaCorrect, | |
50 SkSurfaceProps::kLegacyFontHost_InitType); | 47 SkSurfaceProps::kLegacyFontHost_InitType); |
51 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
&props)); | 48 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0,
&props)); |
52 SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas; | 49 SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas; |
53 // init our new canvas with the old canvas's matrix | 50 // init our new canvas with the old canvas's matrix |
54 canvas->setMatrix(inputCanvas->getTotalMatrix()); | 51 canvas->setMatrix(inputCanvas->getTotalMatrix()); |
55 #else | 52 #else |
56 SkCanvas* canvas = inputCanvas; | 53 SkCanvas* canvas = inputCanvas; |
57 #endif | 54 #endif |
58 // apply global scale to test glyph positioning | 55 // apply global scale to test glyph positioning |
59 canvas->scale(1.05f, 1.05f); | 56 canvas->scale(1.05f, 1.05f); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 200 } |
204 | 201 |
205 private: | 202 private: |
206 sk_sp<SkTypeface> fEmojiTypeface; | 203 sk_sp<SkTypeface> fEmojiTypeface; |
207 const char* fEmojiText; | 204 const char* fEmojiText; |
208 | 205 |
209 typedef skiagm::GM INHERITED; | 206 typedef skiagm::GM INHERITED; |
210 }; | 207 }; |
211 | 208 |
212 DEF_GM(return new DFTextGM;) | 209 DEF_GM(return new DFTextGM;) |
OLD | NEW |