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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 60 bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
61 #if 0 | |
62 SkColorTable* ctable = bm->getColorTable(); | |
63 if (ctable) { | |
64 ctable->setIsOpaque(isOpaque); | |
65 } | |
66 #endif | |
67 } | 61 } |
68 | 62 |
69 virtual void onDrawContent(SkCanvas* canvas) { | 63 virtual void onDrawContent(SkCanvas* canvas) { |
70 SkShader* s = SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMo
de, | 64 SkShader* s = SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMo
de, |
71 SkShader::kMirror_TileMode); | 65 SkShader::kMirror_TileMode); |
72 SkPaint paint; | 66 SkPaint paint; |
73 paint.setShader(s)->unref(); | 67 paint.setShader(s)->unref(); |
74 canvas->drawPaint(paint); | 68 canvas->drawPaint(paint); |
75 } | 69 } |
76 | 70 |
77 private: | 71 private: |
78 typedef SkView INHERITED; | 72 typedef SkView INHERITED; |
79 }; | 73 }; |
80 | 74 |
81 ////////////////////////////////////////////////////////////////////////////// | 75 ////////////////////////////////////////////////////////////////////////////// |
82 | 76 |
83 static SkView* MyFactory() { return new TinyBitmapView; } | 77 static SkView* MyFactory() { return new TinyBitmapView; } |
84 static SkViewRegister reg(MyFactory); | 78 static SkViewRegister reg(MyFactory); |
OLD | NEW |