OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_graphics_2d.h" | 5 #include "webkit/glue/plugins/pepper_graphics_2d.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/task.h" | 11 #include "base/task.h" |
12 #include "gfx/blit.h" | 12 #include "gfx/blit.h" |
13 #include "gfx/point.h" | 13 #include "gfx/point.h" |
14 #include "gfx/rect.h" | 14 #include "gfx/rect.h" |
15 #include "skia/ext/platform_canvas.h" | 15 #include "skia/ext/platform_canvas.h" |
16 #include "third_party/ppapi/c/pp_errors.h" | 16 #include "third_party/ppapi/c/pp_errors.h" |
17 #include "third_party/ppapi/c/pp_module.h" | 17 #include "third_party/ppapi/c/pp_module.h" |
18 #include "third_party/ppapi/c/pp_rect.h" | 18 #include "third_party/ppapi/c/pp_rect.h" |
19 #include "third_party/ppapi/c/pp_resource.h" | 19 #include "third_party/ppapi/c/pp_resource.h" |
20 #include "third_party/ppapi/c/ppb_graphics_2d.h" | 20 #include "third_party/ppapi/c/ppb_graphics_2d.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
22 #include "webkit/glue/plugins/pepper_image_data.h" | 22 #include "webkit/glue/plugins/pepper_image_data.h" |
23 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 23 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
24 #include "webkit/glue/plugins/pepper_plugin_module.h" | 24 #include "webkit/glue/plugins/pepper_plugin_module.h" |
25 | 25 |
26 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
27 #include "base/mac_util.h" | 27 #include "base/mac_util.h" |
28 #include "base/scoped_cftyperef.h" | 28 #include "base/mac/scoped_cftyperef.h" |
29 #endif | 29 #endif |
30 | 30 |
31 namespace pepper { | 31 namespace pepper { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // Converts a rect inside an image of the given dimensions. The rect may be | 35 // Converts a rect inside an image of the given dimensions. The rect may be |
36 // NULL to indicate it should be the entire image. If the rect is outside of | 36 // NULL to indicate it should be the entire image. If the rect is outside of |
37 // the image, this will do nothing and return false. | 37 // the image, this will do nothing and return false. |
38 bool ValidateAndConvertRect(const PP_Rect* rect, | 38 bool ValidateAndConvertRect(const PP_Rect* rect, |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 409 |
410 void Graphics2D::Paint(WebKit::WebCanvas* canvas, | 410 void Graphics2D::Paint(WebKit::WebCanvas* canvas, |
411 const gfx::Rect& plugin_rect, | 411 const gfx::Rect& plugin_rect, |
412 const gfx::Rect& paint_rect) { | 412 const gfx::Rect& paint_rect) { |
413 // We're guaranteed to have a mapped canvas since we mapped it in Init(). | 413 // We're guaranteed to have a mapped canvas since we mapped it in Init(). |
414 const SkBitmap& backing_bitmap = *image_data_->GetMappedBitmap(); | 414 const SkBitmap& backing_bitmap = *image_data_->GetMappedBitmap(); |
415 | 415 |
416 #if defined(OS_MACOSX) | 416 #if defined(OS_MACOSX) |
417 SkAutoLockPixels lock(backing_bitmap); | 417 SkAutoLockPixels lock(backing_bitmap); |
418 | 418 |
419 scoped_cftyperef<CGDataProviderRef> data_provider( | 419 base::mac::ScopedCFTypeRef<CGDataProviderRef> data_provider( |
420 CGDataProviderCreateWithData( | 420 CGDataProviderCreateWithData( |
421 NULL, backing_bitmap.getAddr32(0, 0), | 421 NULL, backing_bitmap.getAddr32(0, 0), |
422 backing_bitmap.rowBytes() * backing_bitmap.height(), NULL)); | 422 backing_bitmap.rowBytes() * backing_bitmap.height(), NULL)); |
423 scoped_cftyperef<CGImageRef> image( | 423 base::mac::ScopedCFTypeRef<CGImageRef> image( |
424 CGImageCreate( | 424 CGImageCreate( |
425 backing_bitmap.width(), backing_bitmap.height(), | 425 backing_bitmap.width(), backing_bitmap.height(), |
426 8, 32, backing_bitmap.rowBytes(), | 426 8, 32, backing_bitmap.rowBytes(), |
427 mac_util::GetSystemColorSpace(), | 427 mac_util::GetSystemColorSpace(), |
428 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, | 428 kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, |
429 data_provider, NULL, false, kCGRenderingIntentDefault)); | 429 data_provider, NULL, false, kCGRenderingIntentDefault)); |
430 | 430 |
431 // Flip the transform | 431 // Flip the transform |
432 CGContextSaveGState(canvas); | 432 CGContextSaveGState(canvas); |
433 float window_height = static_cast<float>(CGBitmapContextGetHeight(canvas)); | 433 float window_height = static_cast<float>(CGBitmapContextGetHeight(canvas)); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 data.Execute(PP_OK); | 549 data.Execute(PP_OK); |
550 } | 550 } |
551 | 551 |
552 bool Graphics2D::HasPendingFlush() const { | 552 bool Graphics2D::HasPendingFlush() const { |
553 return !unpainted_flush_callback_.is_null() || | 553 return !unpainted_flush_callback_.is_null() || |
554 !painted_flush_callback_.is_null() || | 554 !painted_flush_callback_.is_null() || |
555 offscreen_flush_pending_; | 555 offscreen_flush_pending_; |
556 } | 556 } |
557 | 557 |
558 } // namespace pepper | 558 } // namespace pepper |
OLD | NEW |