diff options
author | halcanary <halcanary@google.com> | 2015-08-21 07:47:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-21 07:47:23 -0700 |
commit | 2f0a728e5aed1553811a44c4203b68853255f1bd (patch) | |
tree | 7002fb23b222addcdc57d119436e964a3a91e6b7 /gm/colorwheel.cpp | |
parent | b30e9d3960567571946ed89cbe7f5a2bd8255f85 (diff) |
GMs: change some GMs to use SkImage over SkBitmap
Also, add GetResourceAsImage() to Resources.h
Motivation: test drawImage() as much as we test drawBitmap()
Review URL: https://codereview.chromium.org/1306133003
Diffstat (limited to 'gm/colorwheel.cpp')
-rw-r--r-- | gm/colorwheel.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp index 9af52f2484..dfa81ead70 100644 --- a/gm/colorwheel.cpp +++ b/gm/colorwheel.cpp @@ -7,13 +7,14 @@ #include "Resources.h" #include "SkData.h" +#include "SkImage.h" #include "gm.h" #include "sk_tool_utils.h" -static void draw_bitmap(SkCanvas* canvas, const char* resource, int x, int y) { - SkBitmap bitmap; - if (GetResourceAsBitmap(resource, &bitmap)) { - canvas->drawBitmap(bitmap, SkIntToScalar(x), SkIntToScalar(y)); +static void draw_image(SkCanvas* canvas, const char* resource, int x, int y) { + SkAutoTUnref<SkImage> image(GetResourceAsImage(resource)); + if (image) { + canvas->drawImage(image, SkIntToScalar(x), SkIntToScalar(y)); } else { SkDebugf("\nCould not decode file '%s'. Did you forget" " to set the resourcePath?\n", resource); @@ -31,10 +32,10 @@ static void draw_bitmap(SkCanvas* canvas, const char* resource, int x, int y) { */ DEF_SIMPLE_GM(colorwheel, canvas, 256, 256) { sk_tool_utils::draw_checkerboard(canvas); - draw_bitmap(canvas, "color_wheel.png", 0, 0); // top left - draw_bitmap(canvas, "color_wheel.gif", 128, 0); // top right - draw_bitmap(canvas, "color_wheel.webp", 0, 128); // bottom left - draw_bitmap(canvas, "color_wheel.jpg", 128, 128); // bottom right + draw_image(canvas, "color_wheel.png", 0, 0); // top left + draw_image(canvas, "color_wheel.gif", 128, 0); // top right + draw_image(canvas, "color_wheel.webp", 0, 128); // bottom left + draw_image(canvas, "color_wheel.jpg", 128, 128); // bottom right } DEF_SIMPLE_GM(colorwheelnative, canvas, 128, 28) { |