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

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 180113010: Add SkCanvas::writePixels that takes info+pixels directly (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« 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
(Empty)
1 #include "sk_tool_utils.h"
2
3 namespace sk_tool_utils {
4
5 void config8888_to_imagetypes(SkCanvas::Config8888 config, SkColorType* ct, SkAl phaType* at) {
6 switch (config) {
7 case SkCanvas::kNative_Premul_Config8888:
8 *ct = kPMColor_SkColorType;
9 *at = kPremul_SkAlphaType;
10 break;
11 case SkCanvas::kNative_Unpremul_Config8888:
12 *ct = kPMColor_SkColorType;
13 *at = kUnpremul_SkAlphaType;
14 break;
15 case SkCanvas::kBGRA_Premul_Config8888:
16 *ct = kBGRA_8888_SkColorType;
17 *at = kPremul_SkAlphaType;
18 break;
19 case SkCanvas::kBGRA_Unpremul_Config8888:
20 *ct = kBGRA_8888_SkColorType;
21 *at = kUnpremul_SkAlphaType;
22 break;
23 case SkCanvas::kRGBA_Premul_Config8888:
24 *ct = kRGBA_8888_SkColorType;
25 *at = kPremul_SkAlphaType;
26 break;
27 case SkCanvas::kRGBA_Unpremul_Config8888:
28 *ct = kRGBA_8888_SkColorType;
29 *at = kUnpremul_SkAlphaType;
30 break;
31 default:
32 SkASSERT(0);
33 }
34 }
35
36 void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
37 SkColorType colorType, SkAlphaType alphaType) {
38 SkBitmap tmp(bitmap);
39 tmp.lockPixels();
40
41 SkImageInfo info = tmp.info();
42 info.fColorType = colorType;
43 info.fAlphaType = alphaType;
44
45 canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
46 }
47
48 }
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