| 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 | 7 |
| 8 #include "gm.h" | 8 #include "gm.h" |
| 9 #include "sk_tool_utils.h" | 9 #include "sk_tool_utils.h" |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 | 47 |
| 48 static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) { | 48 static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) { |
| 49 SkAutoCanvasRestore acr(canvas, true); | 49 SkAutoCanvasRestore acr(canvas, true); |
| 50 | 50 |
| 51 SkPaint paint; | 51 SkPaint paint; |
| 52 SkScalar x = 0; | 52 SkScalar x = 0; |
| 53 const int scale = 32; | 53 const int scale = 32; |
| 54 | 54 |
| 55 paint.setAntiAlias(true); | 55 paint.setAntiAlias(true); |
| 56 sk_tool_utils::set_portable_typeface(&paint); | 56 sk_tool_utils::set_portable_typeface_always(&paint); |
| 57 const char* name = sk_tool_utils::colortype_name(bm.colorType()); | 57 const char* name = sk_tool_utils::colortype_name(bm.colorType()); |
| 58 canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8
, | 58 canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8
, |
| 59 paint); | 59 paint); |
| 60 canvas->translate(SkIntToScalar(48), 0); | 60 canvas->translate(SkIntToScalar(48), 0); |
| 61 | 61 |
| 62 canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale)); | 62 canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale)); |
| 63 | 63 |
| 64 x += draw_set(canvas, bm, 0, &paint); | 64 x += draw_set(canvas, bm, 0, &paint); |
| 65 paint.reset(); | 65 paint.reset(); |
| 66 paint.setAlpha(0x80); | 66 paint.setAlpha(0x80); |
| 67 draw_set(canvas, bm, x, &paint); | 67 draw_set(canvas, bm, x, &paint); |
| 68 return x * scale / 3; | 68 return x * scale / 3; |
| 69 } | 69 } |
| 70 | 70 |
| 71 class FilterGM : public skiagm::GM { | 71 class FilterGM : public skiagm::GM { |
| 72 void onOnceBeforeDraw() override { | 72 void onOnceBeforeDraw() override { |
| 73 make_bm(&fBM8); | 73 make_bm(&fBM8); |
| 74 fBM8.copyTo(&fBM4444, kARGB_4444_SkColorType); | 74 fBM8.copyTo(&fBM4444, kARGB_4444_SkColorType); |
| 75 fBM8.copyTo(&fBM16, kRGB_565_SkColorType); | 75 fBM8.copyTo(&fBM16, kRGB_565_SkColorType); |
| 76 fBM8.copyTo(&fBM32, kN32_SkColorType); | 76 fBM8.copyTo(&fBM32, kN32_SkColorType); |
| 77 } | 77 } |
| 78 | 78 |
| 79 public: | 79 public: |
| 80 SkBitmap fBM8, fBM4444, fBM16, fBM32; | 80 SkBitmap fBM8, fBM4444, fBM16, fBM32; |
| 81 | 81 |
| 82 FilterGM() { | 82 FilterGM() { |
| 83 this->setBGColor(0xFFDDDDDD); | 83 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 protected: | 86 protected: |
| 87 SkString onShortName() override { | 87 SkString onShortName() override { |
| 88 return SkString("bitmapfilters"); | 88 return SkString("bitmapfilters"); |
| 89 } | 89 } |
| 90 | 90 |
| 91 SkISize onISize() override { | 91 SkISize onISize() override { |
| 92 return SkISize::Make(540, 330); | 92 return SkISize::Make(540, 330); |
| 93 } | 93 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 canvas->drawBitmap(fBitmap, 10, 10, &paint); // should stay blue (ign
ore paint's color) | 153 canvas->drawBitmap(fBitmap, 10, 10, &paint); // should stay blue (ign
ore paint's color) |
| 154 canvas->drawBitmap(fAlpha, 120, 10, &paint); // should draw red | 154 canvas->drawBitmap(fAlpha, 120, 10, &paint); // should draw red |
| 155 } | 155 } |
| 156 | 156 |
| 157 private: | 157 private: |
| 158 typedef skiagm::GM INHERITED; | 158 typedef skiagm::GM INHERITED; |
| 159 }; | 159 }; |
| 160 DEF_GM( return new TestExtractAlphaGM; ) | 160 DEF_GM( return new TestExtractAlphaGM; ) |
| 161 | 161 |
| OLD | NEW |