blob: 4debacc6d77935e9bebdddf5f7de0d7971ab5139 [file] [log] [blame]
junov@google.com869d6d92011-05-17 15:47:10 +00001#include "SampleCode.h"
2#include "SkCanvas.h"
3
4namespace {
5SkBitmap make_bitmap() {
6 SkBitmap bm;
7 bm.setConfig(SkBitmap::kARGB_8888_Config , 10, 10);
8 bm.allocPixels();
9
10 for (int y = 0; y < bm.height(); y++) {
11 uint32_t* p = bm.getAddr32(0, y);
12 for (int x = 0; x < bm.width(); x++) {
13 p[x] = ((x + y) & 1) ? SK_ColorWHITE : SK_ColorBLACK;
14 }
15 }
16 bm.unlockPixels();
17 return bm;
18}
19} // unnamed namespace
20
21class TextureDomainView : public SampleView {
22 SkBitmap fBM;
23
24public:
25 TextureDomainView(){
26 fBM = make_bitmap();
27 }
28
29protected:
30 // overrides from SkEventSink
31 virtual bool onQuery(SkEvent* evt) {
32 if (SampleCode::TitleQ(*evt)) {
33 SampleCode::TitleR(evt, "Texture Domian");
34 return true;
35 }
36 return this->INHERITED::onQuery(evt);
37 }
38
39 virtual void onDrawContent(SkCanvas* canvas) {
40 SkIRect srcRect;
41 SkRect dstRect;
42 SkPaint paint;
43 paint.setFilterBitmap(true);
44 srcRect.setXYWH(1, 1, 8, 8);
45 dstRect.setXYWH(10.0f, 10.0f, 810.0f, 810.0f);
46 canvas->drawBitmapRect(fBM, &srcRect, dstRect, &paint);
47 }
48private:
49 typedef SkView INHERITED;
50};
51
52//////////////////////////////////////////////////////////////////////////////
53
54static SkView* MyFactory() { return new TextureDomainView; }
55static SkViewRegister reg(MyFactory);
56