aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-24 17:52:07 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-24 17:52:07 +0000
commitaf562b437e43a99f5371585ba50643b1d88f09e0 (patch)
tree897a659d5f33727b19467bd92661bc41cd32b091 /gm
parenta34b1f8e0bff03c3706ea3d9bdfeba94b6f8eb8b (diff)
Tile large bitmaps that are clipped.
R=robertphillips@google.com Review URL: https://codereview.chromium.org/31033002 git-svn-id: http://skia.googlecode.com/svn/trunk@11951 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r--gm/verylargebitmap.cpp44
1 files changed, 35 insertions, 9 deletions
diff --git a/gm/verylargebitmap.cpp b/gm/verylargebitmap.cpp
index d448d2da02..a9ae46ff24 100644
--- a/gm/verylargebitmap.cpp
+++ b/gm/verylargebitmap.cpp
@@ -7,18 +7,27 @@
#include "gm.h"
#include "SkCanvas.h"
+#include "SkGradientShader.h"
#include "SkPath.h"
-static void make_bm(SkBitmap* bm, int width, int height, SkColor color) {
+static void make_bm(SkBitmap* bm, int width, int height, SkColor colors[2]) {
bm->setConfig(SkBitmap::kARGB_8888_Config, width, height);
bm->allocPixels();
- bm->eraseColor(color);
+ SkCanvas canvas(*bm);
+ SkPoint center = {SkIntToScalar(width)/2, SkIntToScalar(height)/2};
+ SkScalar radius = 40;
+ SkShader* shader = SkGradientShader::CreateRadial(center, radius, colors, NULL, 2,
+ SkShader::kMirror_TileMode);
+ SkPaint paint;
+ paint.setShader(shader)->unref();
+ paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+ canvas.drawPaint(paint);
bm->setImmutable();
}
-static void show_bm(SkCanvas* canvas, int width, int height, SkColor color) {
+static void show_bm(SkCanvas* canvas, int width, int height, SkColor colors[2]) {
SkBitmap bm;
- make_bm(&bm, width, height, color);
+ make_bm(&bm, width, height, colors);
SkPaint paint;
SkRect r;
@@ -56,24 +65,41 @@ protected:
}
virtual SkISize onISize() SK_OVERRIDE {
- return SkISize::Make(640, 480);
+ return SkISize::Make(500, 600);
}
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
int veryBig = 70*1024; // 64K < size
- int big = 60*1024; // 32K < size < 64K
+ int big = 60*1024; // 32K < size < 64K
+ // smaller than many max texture sizes, but large enough to gpu-tile for memory reasons.
+ int medium = 7*1024;
int small = 150;
+ SkColor colors[2];
+
canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
- show_bm(canvas, small, small, SK_ColorRED);
+ colors[0] = SK_ColorRED;
+ colors[1] = SK_ColorGREEN;
+ show_bm(canvas, small, small, colors);
+ canvas->translate(0, SkIntToScalar(150));
+
+ colors[0] = SK_ColorBLUE;
+ colors[1] = SK_ColorMAGENTA;
+ show_bm(canvas, big, small, colors);
canvas->translate(0, SkIntToScalar(150));
- show_bm(canvas, big, small, SK_ColorBLUE);
+ colors[0] = SK_ColorMAGENTA;
+ colors[1] = SK_ColorYELLOW;
+ // as of this writing, the raster code will fail to draw the scaled version
+ // since it has a 64K limit on x,y coordinates... (but gpu should succeed)
+ show_bm(canvas, medium, medium, colors);
canvas->translate(0, SkIntToScalar(150));
+ colors[0] = SK_ColorGREEN;
+ colors[1] = SK_ColorYELLOW;
// as of this writing, the raster code will fail to draw the scaled version
// since it has a 64K limit on x,y coordinates... (but gpu should succeed)
- show_bm(canvas, veryBig, small, SK_ColorGREEN);
+ show_bm(canvas, veryBig, small, colors);
}
private: