Add tinybitmap gm and windows baselines.
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 18 Jul 2011 21:19:31 +0000 (21:19 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 18 Jul 2011 21:19:31 +0000 (21:19 +0000)
Review URL: http://codereview.appspot.com/4674048/

git-svn-id: http://skia.googlecode.com/svn/trunk@1888 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/tinybitmap.cpp [new file with mode: 0644]
gyp/gm.gyp

diff --git a/gm/tinybitmap.cpp b/gm/tinybitmap.cpp
new file mode 100644 (file)
index 0000000..d309970
--- /dev/null
@@ -0,0 +1,61 @@
+#include "gm.h"
+#include "SkColorPriv.h"
+#include "SkShader.h"
+#include "SkCanvas.h"
+#include "SkUtils.h"
+
+namespace skiagm {
+
+static SkBitmap make_bitmap() {
+    SkBitmap bm;
+
+    SkColorTable* ctable = new SkColorTable(1);
+    SkPMColor* c = ctable->lockColors();
+    c[0] = SkPackARGB32(0x80, 0x80, 0, 0);
+    ctable->unlockColors(true);
+
+    bm.setConfig(SkBitmap::kIndex8_Config, 1, 1);
+    bm.allocPixels(ctable);
+    ctable->unref();
+
+    bm.lockPixels();
+    *bm.getAddr8(0, 0) = 0;
+    bm.unlockPixels();
+    return bm;
+}
+
+class TinyBitmapGM : public GM {
+    SkBitmap    fBM;
+public:
+    TinyBitmapGM() {
+        fBM = make_bitmap();
+    }
+    
+protected:
+    SkString onShortName() {
+        return SkString("tinybitmap");
+    }
+
+    virtual SkISize onISize() { return make_isize(100, 100); }
+
+    virtual void onDraw(SkCanvas* canvas) {
+        canvas->drawColor(0xFFDDDDDD);
+        SkShader* s = 
+            SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMode,
+                                         SkShader::kMirror_TileMode);
+        SkPaint paint;
+        paint.setAlpha(0x80);
+        paint.setShader(s)->unref();
+        canvas->drawPaint(paint);
+    }
+    
+private:
+    typedef GM INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static GM* MyFactory(void*) { return new TinyBitmapGM; }
+static GMRegistry reg(MyFactory);
+
+}
index 4ecbb47ef8003f292c854c072756ff2c9c66dcd7..63e4fa06d5ea77acda795ae14ecd3c76655128a8 100644 (file)
@@ -24,6 +24,7 @@
         '../gm/strokes.cpp',
         '../gm/texdata.cpp',
         '../gm/tilemodes.cpp',
+        '../gm/tinybitmap.cpp',
         '../gm/xfermodes.cpp',
         '../gm/shadertext.cpp',
         '../gm/complexclip.cpp',