| 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 "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 virtual bool onQuery(SkEvent* evt) { | 94 virtual bool onQuery(SkEvent* evt) { |
| 95 if (SampleCode::TitleQ(*evt)) { | 95 if (SampleCode::TitleQ(*evt)) { |
| 96 SampleCode::TitleR(evt, "DitherBitmap"); | 96 SampleCode::TitleR(evt, "DitherBitmap"); |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 return this->INHERITED::onQuery(evt); | 99 return this->INHERITED::onQuery(evt); |
| 100 } | 100 } |
| 101 | 101 |
| 102 static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) { | 102 static void setBitmapOpaque(SkBitmap* bm, bool isOpaque) { |
| 103 SkAutoLockPixels alp(*bm); // needed for ctable | 103 SkAutoLockPixels alp(*bm); // needed for ctable |
| 104 bm->setIsOpaque(isOpaque); | 104 bm->setAlphaType(isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
| 105 #if 0 |
| 105 SkColorTable* ctable = bm->getColorTable(); | 106 SkColorTable* ctable = bm->getColorTable(); |
| 106 if (ctable) { | 107 if (ctable) { |
| 107 ctable->setIsOpaque(isOpaque); | 108 ctable->setIsOpaque(isOpaque); |
| 108 } | 109 } |
| 110 #endif |
| 109 } | 111 } |
| 110 | 112 |
| 111 static void draw2(SkCanvas* canvas, const SkBitmap& bm) { | 113 static void draw2(SkCanvas* canvas, const SkBitmap& bm) { |
| 112 SkPaint paint; | 114 SkPaint paint; |
| 113 SkBitmap bitmap(bm); | 115 SkBitmap bitmap(bm); |
| 114 | 116 |
| 115 setBitmapOpaque(&bitmap, false); | 117 setBitmapOpaque(&bitmap, false); |
| 116 paint.setDither(false); | 118 paint.setDither(false); |
| 117 canvas->drawBitmap(bitmap, 0, 0, &paint); | 119 canvas->drawBitmap(bitmap, 0, 0, &paint); |
| 118 paint.setDither(true); | 120 paint.setDither(true); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 138 } | 140 } |
| 139 | 141 |
| 140 private: | 142 private: |
| 141 typedef SampleView INHERITED; | 143 typedef SampleView INHERITED; |
| 142 }; | 144 }; |
| 143 | 145 |
| 144 ////////////////////////////////////////////////////////////////////////////// | 146 ////////////////////////////////////////////////////////////////////////////// |
| 145 | 147 |
| 146 static SkView* MyFactory() { return new DitherBitmapView; } | 148 static SkView* MyFactory() { return new DitherBitmapView; } |
| 147 static SkViewRegister reg(MyFactory); | 149 static SkViewRegister reg(MyFactory); |
| OLD | NEW |