Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Side by Side Diff: samplecode/SampleDitherBitmap.cpp

Issue 25275004: store SkAlphaType inside SkBitmap, on road to support unpremul (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove occurances of setIsOpaque Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 SkColorTable* ctable = bm->getColorTable(); 105 SkColorTable* ctable = bm->getColorTable();
106 if (ctable) { 106 if (ctable) {
107 ctable->setIsOpaque(isOpaque); 107 ctable->setIsOpaque(isOpaque);
108 } 108 }
109 } 109 }
110 110
111 static void draw2(SkCanvas* canvas, const SkBitmap& bm) { 111 static void draw2(SkCanvas* canvas, const SkBitmap& bm) {
112 SkPaint paint; 112 SkPaint paint;
113 SkBitmap bitmap(bm); 113 SkBitmap bitmap(bm);
114 114
(...skipping 23 matching lines...) Expand all
138 } 138 }
139 139
140 private: 140 private:
141 typedef SampleView INHERITED; 141 typedef SampleView INHERITED;
142 }; 142 };
143 143
144 ////////////////////////////////////////////////////////////////////////////// 144 //////////////////////////////////////////////////////////////////////////////
145 145
146 static SkView* MyFactory() { return new DitherBitmapView; } 146 static SkView* MyFactory() { return new DitherBitmapView; }
147 static SkViewRegister reg(MyFactory); 147 static SkViewRegister reg(MyFactory);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698