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

Unified Diff: skia/ext/raster_handle_allocator_win.cc

Issue 2715823002: call UnmapViewOfFile if the context failed (Closed)
Patch Set: use base_makeunique Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/raster_handle_allocator_win.cc
diff --git a/skia/ext/raster_handle_allocator_win.cc b/skia/ext/raster_handle_allocator_win.cc
index f5c4bdd98f9a850a1db32bb8668efb84bfa6b2e4..22d9bf4b0e2d6f43a92d1ea5f42cb2ffca9e0444 100644
--- a/skia/ext/raster_handle_allocator_win.cc
+++ b/skia/ext/raster_handle_allocator_win.cc
@@ -108,6 +108,10 @@ class GDIAllocator : public SkRasterHandleAllocator {
}
};
+void unmap_view_proc(void* pixels, void*) {
+ UnmapViewOfFile(pixels);
+}
+
} // namespace
namespace skia {
@@ -137,8 +141,13 @@ std::unique_ptr<SkCanvas> CreatePlatformCanvasWithSharedSection(
DCHECK(shared_section != NULL);
void* pixels =
MapViewOfFile(shared_section, FILE_MAP_WRITE, 0, 0, row_bytes * height);
- if (pixels)
- return SkCanvas::MakeRasterDirect(info, pixels, row_bytes);
+ if (pixels) {
+ SkBitmap bitmap;
+ if (bitmap.installPixels(info, pixels, row_bytes, nullptr,
+ unmap_view_proc, nullptr)) {
+ return base::MakeUnique<SkCanvas>(bitmap);
+ }
+ }
}
if (failure_type == CRASH_ON_FAILURE)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698