| 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 #if 0 |
| 62 // TODO - I think we just want to not allow this anymore | |
| 63 SkColorTable* ctable = bm->getColorTable(); | 62 SkColorTable* ctable = bm->getColorTable(); |
| 64 if (ctable) { | 63 if (ctable) { |
| 65 ctable->setIsOpaque(isOpaque); | 64 ctable->setIsOpaque(isOpaque); |
| 66 } | 65 } |
| 67 #endif | 66 #endif |
| 68 } | 67 } |
| 69 | 68 |
| 70 virtual void onDrawContent(SkCanvas* canvas) { | 69 virtual void onDrawContent(SkCanvas* canvas) { |
| 71 SkShader* s = SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMo
de, | 70 SkShader* s = SkShader::CreateBitmapShader(fBM, SkShader::kRepeat_TileMo
de, |
| 72 SkShader::kMirror_TileMode); | 71 SkShader::kMirror_TileMode); |
| 73 SkPaint paint; | 72 SkPaint paint; |
| 74 paint.setShader(s)->unref(); | 73 paint.setShader(s)->unref(); |
| 75 canvas->drawPaint(paint); | 74 canvas->drawPaint(paint); |
| 76 } | 75 } |
| 77 | 76 |
| 78 private: | 77 private: |
| 79 typedef SkView INHERITED; | 78 typedef SkView INHERITED; |
| 80 }; | 79 }; |
| 81 | 80 |
| 82 ////////////////////////////////////////////////////////////////////////////// | 81 ////////////////////////////////////////////////////////////////////////////// |
| 83 | 82 |
| 84 static SkView* MyFactory() { return new TinyBitmapView; } | 83 static SkView* MyFactory() { return new TinyBitmapView; } |
| 85 static SkViewRegister reg(MyFactory); | 84 static SkViewRegister reg(MyFactory); |
| OLD | NEW |