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

Side by Side Diff: chrome/renderer/pepper/pepper_pdf_host.cc

Issue 16605006: Clean up Pepper ImageData resource class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add NOTREACHED if creating PlatformImageData in NaCl. Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/pepper/pepper_video_source_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/strings/utf_string_conversions.h" 7 #include "base/strings/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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 PP_Instance instance, 356 PP_Instance instance,
357 PP_ImageDataFormat format, 357 PP_ImageDataFormat format,
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 ppapi::PPB_ImageData_Shared::PLATFORM,
366 format, size, 367 format, size,
367 false /* init_to_zero */, 368 false /* init_to_zero */,
368 false /* is_nacl_plugin */,
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
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/pepper_video_source_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698