aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/verylargebitmap.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-07 14:05:14 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-07 14:05:14 +0000
commit7eb3a2653bf18e7c3cadaa5663d4d0060c728b5a (patch)
treec0a283798d49b12214d5d7791a87cc75532b3e39 /gm/verylargebitmap.cpp
parent702ee4fb2885144cd8647aa13564541da2933886 (diff)
add gm for very large bitmaps (>32K >64K)
raster expected to fail when scaling >64K (for now) git-svn-id: http://skia.googlecode.com/svn/trunk@4967 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/verylargebitmap.cpp')
-rw-r--r--gm/verylargebitmap.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/gm/verylargebitmap.cpp b/gm/verylargebitmap.cpp
new file mode 100644
index 0000000000..970ec65c5f
--- /dev/null
+++ b/gm/verylargebitmap.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkPath.h"
+
+static void make_bm(SkBitmap* bm, int width, int height, SkColor color) {
+ bm->setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bm->allocPixels();
+ bm->eraseColor(color);
+ bm->setImmutable();
+}
+
+static void show_bm(SkCanvas* canvas, int width, int height, SkColor color) {
+ SkBitmap bm;
+ make_bm(&bm, width, height, color);
+
+ SkPaint paint;
+ SkRect r;
+ SkIRect ir;
+
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ ir.set(0, 0, 128, 128);
+ r.set(ir);
+
+ canvas->save();
+ canvas->clipRect(r);
+ canvas->drawBitmap(bm, 0, 0, NULL);
+ canvas->restore();
+ canvas->drawRect(r, paint);
+
+ r.offset(SkIntToScalar(150), 0);
+ // exercises extract bitmap, but not shader
+ canvas->drawBitmapRect(bm, &ir, r, NULL);
+ canvas->drawRect(r, paint);
+
+ r.offset(SkIntToScalar(150), 0);
+ // exercises bitmapshader
+ canvas->drawBitmapRect(bm, NULL, r, NULL);
+ canvas->drawRect(r, paint);
+}
+
+class VeryLargeBitmapGM : public skiagm::GM {
+public:
+ VeryLargeBitmapGM() {}
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("verylargebitmap");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(640, 480);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ int veryBig = 100*1024; // 64K < size
+ int big = 60*1024; // 32K < size < 64K
+ int small = 300;
+
+ canvas->translate(SkIntToScalar(10), SkIntToScalar(10));
+ show_bm(canvas, small, small, SK_ColorRED);
+ canvas->translate(0, SkIntToScalar(150));
+
+ show_bm(canvas, big, small, SK_ColorBLUE);
+ canvas->translate(0, SkIntToScalar(150));
+
+ // 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);
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static skiagm::GM* MyFactory(void*) { return new VeryLargeBitmapGM; }
+static skiagm::GMRegistry reg(MyFactory);
+