Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1118)

Unified Diff: gm/colorwheel.cpp

Issue 1306133003: GMs: change some GMs to use SkImage over SkBitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gm/grayscalejpg.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/colorwheel.cpp
diff --git a/gm/colorwheel.cpp b/gm/colorwheel.cpp
index 9af52f2484981e56836d88df2a9dfbcf5974afd4..dfa81ead7043c16d472d23f8fdae78cf3d165553 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) {
« no previous file with comments | « no previous file | gm/grayscalejpg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698