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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/sk_tool_utils.cpp
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f5b8b9f93d055370ae3b89dc5418f4a97da7bafd
--- /dev/null
+++ b/tools/sk_tool_utils.cpp
@@ -0,0 +1,48 @@
+#include "sk_tool_utils.h"
+
+namespace sk_tool_utils {
+
+void config8888_to_imagetypes(SkCanvas::Config8888 config, SkColorType* ct, SkAlphaType* at) {
+ switch (config) {
+ case SkCanvas::kNative_Premul_Config8888:
+ *ct = kPMColor_SkColorType;
+ *at = kPremul_SkAlphaType;
+ break;
+ case SkCanvas::kNative_Unpremul_Config8888:
+ *ct = kPMColor_SkColorType;
+ *at = kUnpremul_SkAlphaType;
+ break;
+ case SkCanvas::kBGRA_Premul_Config8888:
+ *ct = kBGRA_8888_SkColorType;
+ *at = kPremul_SkAlphaType;
+ break;
+ case SkCanvas::kBGRA_Unpremul_Config8888:
+ *ct = kBGRA_8888_SkColorType;
+ *at = kUnpremul_SkAlphaType;
+ break;
+ case SkCanvas::kRGBA_Premul_Config8888:
+ *ct = kRGBA_8888_SkColorType;
+ *at = kPremul_SkAlphaType;
+ break;
+ case SkCanvas::kRGBA_Unpremul_Config8888:
+ *ct = kRGBA_8888_SkColorType;
+ *at = kUnpremul_SkAlphaType;
+ break;
+ default:
+ SkASSERT(0);
+ }
+}
+
+void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y,
+ SkColorType colorType, SkAlphaType alphaType) {
+ SkBitmap tmp(bitmap);
+ tmp.lockPixels();
+
+ SkImageInfo info = tmp.info();
+ info.fColorType = colorType;
+ info.fAlphaType = alphaType;
+
+ canvas->writePixels(info, tmp.getPixels(), tmp.rowBytes(), x, y);
+}
+
+}
« 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