aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleTextureDomain.cpp
diff options
context:
space:
mode:
authorGravatar junov@google.com <junov@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-17 15:47:10 +0000
committerGravatar junov@google.com <junov@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-17 15:47:10 +0000
commit869d6d9f4d5057c736c28749740550f367fcf9b7 (patch)
tree7e8372d71326d3569c86ae3767cee5f1d6dd51db /samplecode/SampleTextureDomain.cpp
parent6fb8f77abb561cec3eeb2d5c71ae9196770ddf00 (diff)
Adding a test to sampleapp for texture domain
git-svn-id: http://skia.googlecode.com/svn/trunk@1347 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleTextureDomain.cpp')
-rwxr-xr-xsamplecode/SampleTextureDomain.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/samplecode/SampleTextureDomain.cpp b/samplecode/SampleTextureDomain.cpp
new file mode 100755
index 0000000000..4debacc6d7
--- /dev/null
+++ b/samplecode/SampleTextureDomain.cpp
@@ -0,0 +1,56 @@
+#include "SampleCode.h"
+#include "SkCanvas.h"
+
+namespace {
+SkBitmap make_bitmap() {
+ SkBitmap bm;
+ bm.setConfig(SkBitmap::kARGB_8888_Config , 10, 10);
+ bm.allocPixels();
+
+ for (int y = 0; y < bm.height(); y++) {
+ uint32_t* p = bm.getAddr32(0, y);
+ for (int x = 0; x < bm.width(); x++) {
+ p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
+ }
+ }
+ bm.unlockPixels();
+ return bm;
+}
+} // unnamed namespace
+
+class TextureDomainView : public SampleView {
+ SkBitmap fBM;
+
+public:
+ TextureDomainView(){
+ fBM = make_bitmap();
+ }
+
+protected:
+ // overrides from SkEventSink
+ virtual bool onQuery(SkEvent* evt) {
+ if (SampleCode::TitleQ(*evt)) {
+ SampleCode::TitleR(evt, "Texture Domian");
+ return true;
+ }
+ return this->INHERITED::onQuery(evt);
+ }
+
+ virtual void onDrawContent(SkCanvas* canvas) {
+ SkIRect srcRect;
+ SkRect dstRect;
+ SkPaint paint;
+ paint.setFilterBitmap(true);
+ srcRect.setXYWH(1, 1, 8, 8);
+ dstRect.setXYWH(10.0f, 10.0f, 810.0f, 810.0f);
+ canvas->drawBitmapRect(fBM, &srcRect, dstRect, &paint);
+ }
+private:
+ typedef SkView INHERITED;
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+static SkView* MyFactory() { return new TextureDomainView; }
+static SkViewRegister reg(MyFactory);
+