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

Unified Diff: skia/ext/platform_canvas.cc

Issue 2622713002: Remove bitmap_platform_device_skia (Closed)
Patch Set: Win build fix Created 3 years, 11 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 | « skia/ext/platform_canvas.h ('k') | ui/snapshot/snapshot_aura_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/platform_canvas.cc
diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc
index 81f8ff584128b37cba10e57cfa20b9a74049675b..cf67ac5da8bd8fe65388de4657189220eff00f21 100644
--- a/skia/ext/platform_canvas.cc
+++ b/skia/ext/platform_canvas.cc
@@ -62,16 +62,6 @@ size_t PlatformCanvasStrideForWidth(unsigned width) {
return 4 * width;
}
-std::unique_ptr<SkCanvas> CreateCanvas(const sk_sp<SkBaseDevice>& device,
- OnFailureType failureType) {
- if (!device) {
- if (CRASH_ON_FAILURE == failureType)
- SK_CRASH();
- return nullptr;
- }
- return base::MakeUnique<SkCanvas>(device.get());
-}
-
SkMetaData& GetMetaData(const SkCanvas& canvas) {
return const_cast<SkCanvas&>(canvas).getMetaData();
}
@@ -86,4 +76,37 @@ bool IsPreviewMetafile(const SkCanvas& canvas) {
}
#endif
+#if !defined(WIN32)
+
+std::unique_ptr<SkCanvas> CreatePlatformCanvasWithPixels(
+ int width,
+ int height,
+ bool is_opaque,
+ uint8_t* data,
+ OnFailureType failureType) {
+
+ SkBitmap bitmap;
+ bitmap.setInfo(SkImageInfo::MakeN32(width, height,
+ is_opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType));
+
+ if (data) {
+ bitmap.setPixels(data);
+ } else {
+ if (!bitmap.tryAllocPixels()) {
+ if (CRASH_ON_FAILURE == failureType)
+ SK_CRASH();
+ return nullptr;
+ }
+
+ // Follow the logic in SkCanvas::createDevice(), initialize the bitmap if
+ // it is not opaque.
+ if (!is_opaque)
+ bitmap.eraseARGB(0, 0, 0, 0);
+ }
+
+ return base::MakeUnique<SkCanvas>(bitmap);
+}
+
+#endif
+
} // namespace skia
« no previous file with comments | « skia/ext/platform_canvas.h ('k') | ui/snapshot/snapshot_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698