OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 draw_rect_tests(canvas); | 101 draw_rect_tests(canvas); |
102 } | 102 } |
103 | 103 |
104 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } | 104 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } |
105 | 105 |
106 private: | 106 private: |
107 typedef skiagm::GM INHERITED; | 107 typedef skiagm::GM INHERITED; |
108 }; | 108 }; |
109 | 109 |
110 DEF_GM( return SkNEW(AAClipGM); ) | 110 DEF_GM( return SkNEW(AAClipGM); ) |
111 | |
112 ///////////////////////////////////////////////////////////////////////// | |
113 | |
114 #ifdef SK_BUILD_FOR_MAC | |
115 | |
116 #include "SkCGUtils.h" | |
117 static void test_image(SkCanvas* canvas, const SkImageInfo& info) { | |
118 SkBitmap bm; | |
119 bm.allocPixels(info); | |
120 | |
121 SkAutoTUnref<SkCanvas> newc(SkCanvas::NewRasterDirectN32(info.width(), info. height(), | |
122 (SkPMColor*)bm.getP ixels(), | |
123 bm.rowBytes())); | |
124 if (info.isOpaque()) { | |
125 bm.eraseColor(SK_ColorGREEN); | |
126 } else { | |
127 bm.eraseColor(0); | |
128 } | |
129 | |
130 SkPaint paint; | |
131 paint.setAntiAlias(true); | |
132 paint.setColor(SK_ColorRED); | |
133 newc->drawCircle(50, 50, 49, paint); | |
134 canvas->drawBitmap(bm, 10, 10); | |
135 | |
136 CGImageRef image = SkCreateCGImageRefWithColorspace(bm, NULL); | |
137 | |
138 SkBitmap bm2; | |
139 SkCreateBitmapFromCGImage(&bm2, image); | |
140 CGImageRelease(image); | |
141 | |
142 canvas->drawBitmap(bm2, 10, 120); | |
143 } | |
144 | |
145 class CGImageGM : public skiagm::GM { | |
146 public: | |
147 CGImageGM() {} | |
148 | |
149 protected: | |
150 virtual SkString onShortName() SK_OVERRIDE { | |
151 return SkString("cgimage"); | |
152 } | |
153 | |
154 virtual SkISize onISize() SK_OVERRIDE { | |
155 return SkISize::Make(800, 250); | |
156 } | |
157 | |
158 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | |
159 const struct { | |
160 SkColorType fCT; | |
161 SkAlphaType fAT; | |
162 } rec[] = { | |
163 { kRGBA_8888_SkColorType, kPremul_SkAlphaType }, | |
164 { kRGBA_8888_SkColorType, kUnpremul_SkAlphaType }, | |
165 { kRGBA_8888_SkColorType, kOpaque_SkAlphaType }, | |
166 { kBGRA_8888_SkColorType, kPremul_SkAlphaType }, | |
167 { kBGRA_8888_SkColorType, kUnpremul_SkAlphaType }, | |
168 { kBGRA_8888_SkColorType, kOpaque_SkAlphaType }, | |
169 }; | |
170 | |
171 for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) { | |
172 SkImageInfo info = SkImageInfo::Make(100, 100, rec[i].fCT, rec[i].fA T); | |
173 test_image(canvas, info); | |
174 canvas->translate(info.width() + 10, 0); | |
175 } | |
176 } | |
177 | |
178 virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; } | |
scroggo
2014/04/22 14:58:17
SK_OVERRIDE
reed1
2014/04/22 17:51:39
Done.
| |
179 | |
180 private: | |
181 typedef skiagm::GM INHERITED; | |
182 }; | |
183 | |
184 DEF_GM( return SkNEW(CGImageGM); ) | |
185 | |
186 #endif | |
OLD | NEW |