OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 virtual bool onQuery(SkEvent* evt) { | 50 virtual bool onQuery(SkEvent* evt) { |
51 if (SampleCode::TitleQ(*evt)) { | 51 if (SampleCode::TitleQ(*evt)) { |
52 SampleCode::TitleR(evt, "TinyBitmap"); | 52 SampleCode::TitleR(evt, "TinyBitmap"); |
53 return true; | 53 return true; |
54 } | 54 } |
55 return this->INHERITED::onQuery(evt); | 55 return this->INHERITED::onQuery(evt); |
56 } | 56 } |
57 | 57 |
58 static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) { | 58 static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) { |
59 SkAutoLockPixels alp(*bm); // needed for ctable | 59 SkAutoLockPixels alp(*bm); // needed for ctable |
60 bm->setIsOpaque(isOpaque); | 60 bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
| 61 #if 0 |
61 SkColorTable* ctable = bm->getColorTable(); | 62 SkColorTable* ctable = bm->getColorTable(); |
62 if (ctable) { | 63 if (ctable) { |
63 ctable->setIsOpaque(isOpaque); | 64 ctable->setIsOpaque(isOpaque); |
64 } | 65 } |
| 66 #endif |
65 } | 67 } |
66 | 68 |
67 virtual void onDrawContent(SkCanvas* canvas) { | 69 virtual void onDrawContent(SkCanvas* canvas) { |
68 SkShader* s = SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMo
de, | 70 SkShader* s = SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMo
de, |
69 SkShader::kMirror_TileMode); | 71 SkShader::kMirror_TileMode); |
70 SkPaint paint; | 72 SkPaint paint; |
71 paint.setShader(s)->unref(); | 73 paint.setShader(s)->unref(); |
72 canvas->drawPaint(paint); | 74 canvas->drawPaint(paint); |
73 } | 75 } |
74 | 76 |
75 private: | 77 private: |
76 typedef SkView INHERITED; | 78 typedef SkView INHERITED; |
77 }; | 79 }; |
78 | 80 |
79 ////////////////////////////////////////////////////////////////////////////// | 81 ////////////////////////////////////////////////////////////////////////////// |
80 | 82 |
81 static SkView* MyFactory() { return new TinyBitmapView; } | 83 static SkView* MyFactory() { return new TinyBitmapView; } |
82 static SkViewRegister reg(MyFactory); | 84 static SkViewRegister reg(MyFactory); |
OLD | NEW |