From 8c23a87bd4f1c7aa5b7426bc6e0ab4f959669cbf Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Fri, 28 Jan 2011 20:01:41 +0000 Subject: Ensure the plugin backing store is always mapped, even when it's been swapped in. This was causing a crash after Swap when running out of process. TEST=manual BUG=none Review URL: http://codereview.chromium.org/5972010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73004 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/plugins/ppapi/ppb_graphics_2d_impl.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'webkit') diff --git a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc index 3105b61..28c8a7b 100644 --- a/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc +++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc @@ -79,9 +79,12 @@ void ConvertBetweenBGRAandRGBA(const uint32_t* input, } // Converts ImageData from PP_IMAGEDATAFORMAT_BGRA_PREMUL to -// PP_IMAGEDATAFORMAT_RGBA_PREMUL, or reverse. +// PP_IMAGEDATAFORMAT_RGBA_PREMUL, or reverse. It's assumed that the +// destination image is always mapped (so will have non-NULL data). void ConvertImageData(PPB_ImageData_Impl* src_image, const SkIRect& src_rect, PPB_ImageData_Impl* dest_image, const SkRect& dest_rect) { + ImageDataAutoMapper auto_mapper(src_image); + DCHECK(src_image->format() != dest_image->format()); DCHECK(PPB_ImageData_Impl::IsImageDataFormatSupported(src_image->format())); DCHECK(PPB_ImageData_Impl::IsImageDataFormatSupported(dest_image->format())); @@ -430,7 +433,6 @@ bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image, SkIntToScalar(image_resource->width()), SkIntToScalar(image_resource->height()) }; - ImageDataAutoMapper auto_mapper2(image_data_); if (image_resource->format() != image_data_->format()) { // Convert the image data if the format does not match. ConvertImageData(image_data_, src_irect, image_resource.get(), dest_rect); @@ -636,6 +638,11 @@ void PPB_Graphics2D_Impl::ExecuteReplaceContents(PPB_ImageData_Impl* image, SkIntToScalar(image_data_->height()) }; ConvertImageData(image, src_irect, image_data_, dest_rect); } else { + // The passed-in image may not be mapped in our process, and we need to + // guarantee that the current backing store is always mapped. + if (!image->Map()) + return; + image_data_->Unmap(); image_data_->Swap(image); } *invalidated_rect = gfx::Rect(0, 0, -- cgit v1.1