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

Side by Side Diff: gm/all_bitmap_configs.cpp

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage Created 4 years, 9 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
« no previous file with comments | « gm/SkLinearBitmapPipelineGM.cpp ('k') | gm/astcbitmap.cpp » ('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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "SkSurface.h" 9 #include "SkSurface.h"
10 #include "Resources.h" 10 #include "Resources.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType); 185 SkBitmap bitmapA8 = make_bitmap(kAlpha_8_SkColorType);
186 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8"); 186 draw(canvas, p, bitmapA8, kAlpha_8_SkColorType, "Alpha 8");
187 187
188 p.setColor(SK_ColorRED); 188 p.setColor(SK_ColorRED);
189 canvas->translate(0.0f, SkIntToScalar(SCALE)); 189 canvas->translate(0.0f, SkIntToScalar(SCALE));
190 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType); 190 SkBitmap bitmapG8 = make_bitmap(kGray_8_SkColorType);
191 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8"); 191 draw(canvas, p, bitmapG8, kGray_8_SkColorType, "Gray 8");
192 } 192 }
193 193
194 // Works on Ganesh, fails on Raster. 194 // Works on Ganesh, fails on Raster.
195 SkImage* make_not_native32_color_wheel() { 195 sk_sp<SkImage> make_not_native32_color_wheel() {
196 SkBitmap n32bitmap, notN32bitmap; 196 SkBitmap n32bitmap, notN32bitmap;
197 n32bitmap.allocN32Pixels(SCALE, SCALE); 197 n32bitmap.allocN32Pixels(SCALE, SCALE);
198 n32bitmap.eraseColor(SK_ColorTRANSPARENT); 198 n32bitmap.eraseColor(SK_ColorTRANSPARENT);
199 SkCanvas n32canvas(n32bitmap); 199 SkCanvas n32canvas(n32bitmap);
200 color_wheel_native(&n32canvas); 200 color_wheel_native(&n32canvas);
201 n32canvas.flush(); 201 n32canvas.flush();
202 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) 202 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
203 const SkColorType ct = kRGBA_8888_SkColorType; 203 const SkColorType ct = kRGBA_8888_SkColorType;
204 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) 204 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
205 const SkColorType ct = kBGRA_8888_SkColorType; 205 const SkColorType ct = kBGRA_8888_SkColorType;
206 #endif 206 #endif
207 static_assert(ct != kN32_SkColorType, "BRGA!=RGBA"); 207 static_assert(ct != kN32_SkColorType, "BRGA!=RGBA");
208 SkAssertResult(n32bitmap.copyTo(&notN32bitmap, ct)); 208 SkAssertResult(n32bitmap.copyTo(&notN32bitmap, ct));
209 SkASSERT(notN32bitmap.colorType() == ct); 209 SkASSERT(notN32bitmap.colorType() == ct);
210 return SkImage::NewFromBitmap(notN32bitmap); 210 return SkImage::MakeFromBitmap(notN32bitmap);
211 } 211 }
212 212
213 DEF_SIMPLE_GM(not_native32_bitmap_config, canvas, SCALE, SCALE) { 213 DEF_SIMPLE_GM(not_native32_bitmap_config, canvas, SCALE, SCALE) {
214 SkAutoTUnref<SkImage> notN32image(make_not_native32_color_wheel()); 214 sk_sp<SkImage> notN32image(make_not_native32_color_wheel());
215 SkASSERT(notN32image); 215 SkASSERT(notN32image);
216 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8); 216 sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
217 canvas->drawImage(notN32image, 0.0f, 0.0f); 217 canvas->drawImage(notN32image.get(), 0.0f, 0.0f);
218 } 218 }
OLDNEW
« no previous file with comments | « gm/SkLinearBitmapPipelineGM.cpp ('k') | gm/astcbitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698