OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkGradientShader.h" | 9 #include "SkGradientShader.h" |
10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 // must be opaque to have a hope of testing LCD text | 79 // must be opaque to have a hope of testing LCD text |
80 const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType, | 80 const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType, |
81 canvas->imageInfo().profil
eType()); | 81 canvas->imageInfo().profil
eType()); |
82 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); | 82 SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType); |
83 bool gammaCorrect = canvas->getProps(&canvasProps) && canvasProps.isGamm
aCorrect(); | 83 bool gammaCorrect = canvas->getProps(&canvasProps) && canvasProps.isGamm
aCorrect(); |
84 | 84 |
85 const struct { | 85 const struct { |
86 SkPixelGeometry fGeo; | 86 SkPixelGeometry fGeo; |
87 const char* fLabel; | 87 const char* fLabel; |
88 } rec[] = { | 88 } recs[] = { |
89 { kUnknown_SkPixelGeometry, "Unknown" }, | 89 { kUnknown_SkPixelGeometry, "Unknown" }, |
90 { kRGB_H_SkPixelGeometry, "RGB_H" }, | 90 { kRGB_H_SkPixelGeometry, "RGB_H" }, |
91 { kBGR_H_SkPixelGeometry, "BGR_H" }, | 91 { kBGR_H_SkPixelGeometry, "BGR_H" }, |
92 { kRGB_V_SkPixelGeometry, "RGB_V" }, | 92 { kRGB_V_SkPixelGeometry, "RGB_V" }, |
93 { kBGR_V_SkPixelGeometry, "BGR_V" }, | 93 { kBGR_V_SkPixelGeometry, "BGR_V" }, |
94 }; | 94 }; |
95 | 95 |
96 SkScalar x = 0; | 96 SkScalar x = 0; |
97 for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) { | 97 for (int disallowAA = 0; disallowAA <= 1; ++disallowAA) { |
98 for (int disallowDither = 0; disallowDither <= 1; ++disallowDither)
{ | 98 for (int disallowDither = 0; disallowDither <= 1; ++disallowDither)
{ |
99 SkScalar y = 0; | 99 SkScalar y = 0; |
100 for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { | 100 for (const auto& rec : recs) { |
101 auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA
, disallowDither, | 101 auto surface(make_surface(ctx, info, rec.fGeo, disallowAA, d
isallowDither, |
102 gammaCorrect)); | 102 gammaCorrect)); |
103 test_draw(surface->getCanvas(), rec[i].fLabel); | 103 if (!surface) { |
| 104 SkDebugf("failed to create surface! label: %s AA: %s dit
her: %s\n", |
| 105 rec.fLabel, (disallowAA == 1 ? "disallowed" : "
allowed"), |
| 106 (disallowDither == 1 ? "disallowed" : "allowed"
)); |
| 107 continue; |
| 108 } |
| 109 test_draw(surface->getCanvas(), rec.fLabel); |
104 surface->draw(canvas, x, y, nullptr); | 110 surface->draw(canvas, x, y, nullptr); |
105 y += H; | 111 y += H; |
106 } | 112 } |
107 x += W; | 113 x += W; |
108 } | 114 } |
109 } | 115 } |
110 } | 116 } |
111 | 117 |
112 private: | 118 private: |
113 typedef GM INHERITED; | 119 typedef GM INHERITED; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 SkASSERT(equal(surf->props(), surf2->props())); | 162 SkASSERT(equal(surf->props(), surf2->props())); |
157 | 163 |
158 sk_sp<SkImage> image2(surf2->makeImageSnapshot()); | 164 sk_sp<SkImage> image2(surf2->makeImageSnapshot()); |
159 canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10,
10, nullptr); | 165 canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10,
10, nullptr); |
160 } | 166 } |
161 | 167 |
162 private: | 168 private: |
163 typedef GM INHERITED; | 169 typedef GM INHERITED; |
164 }; | 170 }; |
165 DEF_GM( return new NewSurfaceGM ) | 171 DEF_GM( return new NewSurfaceGM ) |
OLD | NEW |