| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/pepper/pepper_pdf_host.h" | 5 #include "chrome/renderer/pepper/pepper_pdf_host.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
| 9 #include "chrome/renderer/printing/print_web_view_helper.h" | 9 #include "chrome/renderer/printing/print_web_view_helper.h" |
| 10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 const PP_Size& size, | 358 const PP_Size& size, |
| 359 const SkBitmap& pixels_to_write, | 359 const SkBitmap& pixels_to_write, |
| 360 ppapi::HostResource* result, | 360 ppapi::HostResource* result, |
| 361 PP_ImageDataDesc* out_image_data_desc, | 361 PP_ImageDataDesc* out_image_data_desc, |
| 362 IPC::PlatformFileForTransit* out_image_handle, | 362 IPC::PlatformFileForTransit* out_image_handle, |
| 363 uint32_t* out_byte_count) { | 363 uint32_t* out_byte_count) { |
| 364 PP_Resource resource = ppapi::proxy::PPB_ImageData_Proxy::CreateImageData( | 364 PP_Resource resource = ppapi::proxy::PPB_ImageData_Proxy::CreateImageData( |
| 365 instance, | 365 instance, |
| 366 format, size, | 366 format, size, |
| 367 false /* init_to_zero */, | 367 false /* init_to_zero */, |
| 368 false /* is_nacl_plugin */, | 368 true /* platform */, |
| 369 out_image_data_desc, out_image_handle, out_byte_count); | 369 out_image_data_desc, out_image_handle, out_byte_count); |
| 370 if (!resource) | 370 if (!resource) |
| 371 return false; | 371 return false; |
| 372 | 372 |
| 373 result->SetHostResource(instance, resource); | 373 result->SetHostResource(instance, resource); |
| 374 | 374 |
| 375 // Write the image to the resource shared memory. | 375 // Write the image to the resource shared memory. |
| 376 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> | 376 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_ImageData_API> |
| 377 enter_resource(resource, false); | 377 enter_resource(resource, false); |
| 378 if (enter_resource.failed()) | 378 if (enter_resource.failed()) |
| 379 return false; | 379 return false; |
| 380 | 380 |
| 381 webkit::ppapi::PPB_ImageData_Impl* image_data = | 381 webkit::ppapi::PPB_ImageData_Impl* image_data = |
| 382 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter_resource.object()); | 382 static_cast<webkit::ppapi::PPB_ImageData_Impl*>(enter_resource.object()); |
| 383 webkit::ppapi::ImageDataAutoMapper mapper(image_data); | 383 webkit::ppapi::ImageDataAutoMapper mapper(image_data); |
| 384 if (!mapper.is_valid()) | 384 if (!mapper.is_valid()) |
| 385 return false; | 385 return false; |
| 386 | 386 |
| 387 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); | 387 skia::PlatformCanvas* canvas = image_data->GetPlatformCanvas(); |
| 388 // Note: Do not skBitmap::copyTo the canvas bitmap directly because it will | 388 // Note: Do not skBitmap::copyTo the canvas bitmap directly because it will |
| 389 // ignore the allocated pixels in shared memory and re-allocate a new buffer. | 389 // ignore the allocated pixels in shared memory and re-allocate a new buffer. |
| 390 canvas->writePixels(pixels_to_write, 0, 0); | 390 canvas->writePixels(pixels_to_write, 0, 0); |
| 391 | 391 |
| 392 return true; | 392 return true; |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace chrome | 395 } // namespace chrome |
| OLD | NEW |