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

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 348623006: Add GYP target for sk_tool_utils.* component. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tools.gyp Created 6 years, 6 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 | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #include "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
2 9
10 #include "SkBitmap.h"
11 #include "SkCanvas.h"
12
3 namespace sk_tool_utils { 13 namespace sk_tool_utils {
4 14
5 const char* colortype_name(SkColorType ct) { 15 const char* colortype_name(SkColorType ct) {
6 switch (ct) { 16 switch (ct) {
7 case kUnknown_SkColorType: return "Unknown"; 17 case kUnknown_SkColorType: return "Unknown";
8 case kAlpha_8_SkColorType: return "Alpha_8"; 18 case kAlpha_8_SkColorType: return "Alpha_8";
9 case kIndex_8_SkColorType: return "Index_8"; 19 case kIndex_8_SkColorType: return "Index_8";
10 case kARGB_4444_SkColorType: return "ARGB_4444"; 20 case kARGB_4444_SkColorType: return "ARGB_4444";
11 case kRGB_565_SkColorType: return "RGB_565"; 21 case kRGB_565_SkColorType: return "RGB_565";
12 case kRGBA_8888_SkColorType: return "RGBA_8888"; 22 case kRGBA_8888_SkColorType: return "RGBA_8888";
13 case kBGRA_8888_SkColorType: return "BGRA_8888"; 23 case kBGRA_8888_SkColorType: return "BGRA_8888";
14 default: 24 default:
15 SkASSERT(false); 25 SkASSERT(false);
16 return "unexpected colortype"; 26 return "unexpected colortype";
17 } 27 }
18 } 28 }
19 29
20 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y, 30 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
21 SkColorType colorType, SkAlphaType alphaType) { 31 SkColorType colorType, SkAlphaType alphaType) {
22 SkBitmap tmp(bitmap); 32 SkBitmap tmp(bitmap);
23 tmp.lockPixels(); 33 tmp.lockPixels();
24 34
25 SkImageInfo info = tmp.info(); 35 SkImageInfo info = tmp.info();
26 info.fColorType = colorType; 36 info.fColorType = colorType;
27 info.fAlphaType = alphaType; 37 info.fAlphaType = alphaType;
28 38
29 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y); 39 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
30 } 40 }
31 41
32 } 42 } // namespace sk_tool_utils
OLDNEW
« no previous file with comments | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698