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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return SkISize::Make(W * 4, H * 5); | 73 return SkISize::Make(W * 4, H * 5); |
74 } | 74 } |
75 | 75 |
76 void onDraw(SkCanvas* canvas) override { | 76 void onDraw(SkCanvas* canvas) override { |
77 GrContext* ctx = canvas->getGrContext(); | 77 GrContext* ctx = canvas->getGrContext(); |
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 gammaCorrrect = canvas->getProps(&canvasProps) && canvasProps.isGam
maCorrect(); | 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 } rec[] = { |
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 (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { |
101 auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA
, disallowDither, | 101 auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA
, disallowDither, |
102 gammaCorrrect)); | 102 gammaCorrect)); |
103 test_draw(surface->getCanvas(), rec[i].fLabel); | 103 test_draw(surface->getCanvas(), rec[i].fLabel); |
104 surface->draw(canvas, x, y, nullptr); | 104 surface->draw(canvas, x, y, nullptr); |
105 y += H; | 105 y += H; |
106 } | 106 } |
107 x += W; | 107 x += W; |
108 } | 108 } |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 SkASSERT(equal(surf->props(), surf2->props())); | 156 SkASSERT(equal(surf->props(), surf2->props())); |
157 | 157 |
158 sk_sp<SkImage> image2(surf2->makeImageSnapshot()); | 158 sk_sp<SkImage> image2(surf2->makeImageSnapshot()); |
159 canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10,
10, nullptr); | 159 canvas->drawImage(image2.get(), 10 + SkIntToScalar(image->width()) + 10,
10, nullptr); |
160 } | 160 } |
161 | 161 |
162 private: | 162 private: |
163 typedef GM INHERITED; | 163 typedef GM INHERITED; |
164 }; | 164 }; |
165 DEF_GM( return new NewSurfaceGM ) | 165 DEF_GM( return new NewSurfaceGM ) |
OLD | NEW |