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

Side by Side Diff: gm/xfermodes.cpp

Issue 169913003: replace SkBitmap::Config with SkColorType in gms (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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
« no previous file with comments | « gm/tinybitmap.cpp ('k') | include/core/SkBitmap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
(...skipping 13 matching lines...) Expand all
24 SkScalar ww = SkIntToScalar(w); 24 SkScalar ww = SkIntToScalar(w);
25 SkScalar hh = SkIntToScalar(h); 25 SkScalar hh = SkIntToScalar(h);
26 26
27 { 27 {
28 SkCanvas c(*src); 28 SkCanvas c(*src);
29 p.setColor(0xFFFFCC44); 29 p.setColor(0xFFFFCC44);
30 r.set(0, 0, ww*3/4, hh*3/4); 30 r.set(0, 0, ww*3/4, hh*3/4);
31 c.drawOval(r, p); 31 c.drawOval(r, p);
32 } 32 }
33 33
34 dst->setConfig(SkBitmap::kARGB_8888_Config, w, h); 34 dst->allocN32Pixels(w, h);
35 dst->allocPixels();
36 dst->eraseColor(SK_ColorTRANSPARENT); 35 dst->eraseColor(SK_ColorTRANSPARENT);
37 36
38 { 37 {
39 SkCanvas c(*dst); 38 SkCanvas c(*dst);
40 p.setColor(0xFF66AAFF); 39 p.setColor(0xFF66AAFF);
41 r.set(ww/3, hh/3, ww*19/20, hh*19/20); 40 r.set(ww/3, hh/3, ww*19/20, hh*19/20);
42 c.drawRect(r, p); 41 c.drawRect(r, p);
43 } 42 }
44 43
45 transparent->setConfig(SkBitmap::kARGB_8888_Config, w, h); 44 transparent->allocN32Pixels(w, h);
46 transparent->allocPixels();
47 transparent->eraseColor(SK_ColorTRANSPARENT); 45 transparent->eraseColor(SK_ColorTRANSPARENT);
48 } 46 }
49 47
50 static uint16_t gData[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF }; 48 static uint16_t gData[] = { 0xFFFF, 0xCCCF, 0xCCCF, 0xFFFF };
51 49
52 class XfermodesGM : public GM { 50 class XfermodesGM : public GM {
53 enum SrcType { 51 enum SrcType {
54 //! A WxH image with a rectangle in the lower right. 52 //! A WxH image with a rectangle in the lower right.
55 kRectangleImage_SrcType = 0x01, 53 kRectangleImage_SrcType = 0x01,
56 //! kRectangleImage_SrcType with an alpha of 34.5%. 54 //! kRectangleImage_SrcType with an alpha of 34.5%.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 default: 141 default:
144 break; 142 break;
145 } 143 }
146 144
147 if (restoreNeeded) { 145 if (restoreNeeded) {
148 canvas->restore(); 146 canvas->restore();
149 } 147 }
150 } 148 }
151 149
152 virtual void onOnceBeforeDraw() SK_OVERRIDE { 150 virtual void onOnceBeforeDraw() SK_OVERRIDE {
153 fBG.setConfig(SkBitmap::kARGB_4444_Config, 2, 2, 4, kOpaque_SkAlphaType) ; 151 fBG.installPixels(SkImageInfo::Make(2, 2, kARGB_4444_SkColorType,
154 fBG.setPixels(gData); 152 kOpaque_SkAlphaType),
153 gData, 4);
155 154
156 make_bitmaps(W, H, &fSrcB, &fDstB, &fTransparent); 155 make_bitmaps(W, H, &fSrcB, &fDstB, &fTransparent);
157 } 156 }
158 157
159 public: 158 public:
160 const static int W = 64; 159 const static int W = 64;
161 const static int H = 64; 160 const static int H = 64;
162 XfermodesGM() {} 161 XfermodesGM() {}
163 162
164 protected: 163 protected:
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 private: 283 private:
285 typedef GM INHERITED; 284 typedef GM INHERITED;
286 }; 285 };
287 286
288 ////////////////////////////////////////////////////////////////////////////// 287 //////////////////////////////////////////////////////////////////////////////
289 288
290 static GM* MyFactory(void*) { return new XfermodesGM; } 289 static GM* MyFactory(void*) { return new XfermodesGM; }
291 static GMRegistry reg(MyFactory); 290 static GMRegistry reg(MyFactory);
292 291
293 } 292 }
OLDNEW
« no previous file with comments | « gm/tinybitmap.cpp ('k') | include/core/SkBitmap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698