OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
6 | 6 |
7 #include <QuartzCore/QuartzCore.h> | 7 #include <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 BackingStore* RenderWidgetHostViewMac::AllocBackingStore( | 827 BackingStore* RenderWidgetHostViewMac::AllocBackingStore( |
828 const gfx::Size& size) { | 828 const gfx::Size& size) { |
829 float scale = ScaleFactor(cocoa_view_); | 829 float scale = ScaleFactor(cocoa_view_); |
830 return new BackingStoreMac(render_widget_host_, size, scale); | 830 return new BackingStoreMac(render_widget_host_, size, scale); |
831 } | 831 } |
832 | 832 |
833 void RenderWidgetHostViewMac::CopyFromCompositingSurface( | 833 void RenderWidgetHostViewMac::CopyFromCompositingSurface( |
834 const gfx::Rect& src_subrect, | 834 const gfx::Rect& src_subrect, |
835 const gfx::Size& dst_size, | 835 const gfx::Size& dst_size, |
836 const base::Callback<void(bool)>& callback, | 836 const base::Callback<void(bool)>& callback, |
837 skia::PlatformCanvas* output) { | 837 skia::PlatformBitmap* output) { |
838 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); | 838 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); |
839 if (!compositing_iosurface_.get() || | 839 if (!compositing_iosurface_.get() || |
840 !compositing_iosurface_->HasIOSurface()) | 840 !compositing_iosurface_->HasIOSurface()) |
841 return; | 841 return; |
842 | 842 |
843 float scale = ScaleFactor(cocoa_view_); | 843 float scale = ScaleFactor(cocoa_view_); |
844 gfx::Size dst_pixel_size = gfx::ToFlooredSize(dst_size.Scale(scale)); | 844 gfx::Size dst_pixel_size = gfx::ToFlooredSize(dst_size.Scale(scale)); |
845 if (!output->initialize( | 845 if (!output->Allocate( |
846 dst_pixel_size.width(), dst_pixel_size.height(), true)) | 846 dst_pixel_size.width(), dst_pixel_size.height(), true)) |
847 return; | 847 return; |
848 scoped_callback_runner.Release(); | 848 scoped_callback_runner.Release(); |
849 | 849 |
850 // Convert |src_subrect| from the views coordinate (upper-left origin) into | 850 // Convert |src_subrect| from the views coordinate (upper-left origin) into |
851 // the OpenGL coordinate (lower-left origin). | 851 // the OpenGL coordinate (lower-left origin). |
852 gfx::Rect src_gl_subrect = src_subrect; | 852 gfx::Rect src_gl_subrect = src_subrect; |
853 src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom()); | 853 src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom()); |
854 | 854 |
855 gfx::Rect src_pixel_gl_subrect = | 855 gfx::Rect src_pixel_gl_subrect = |
856 gfx::ToEnclosingRect(src_gl_subrect.Scale(scale)); | 856 gfx::ToEnclosingRect(src_gl_subrect.Scale(scale)); |
857 compositing_iosurface_->CopyTo( | 857 compositing_iosurface_->CopyTo( |
858 src_pixel_gl_subrect, | 858 src_pixel_gl_subrect, |
859 dst_pixel_size, | 859 dst_pixel_size, |
860 output->getTopDevice()->accessBitmap(true).getPixels(), | 860 output->GetBitmap().getPixels(), |
861 callback); | 861 callback); |
862 } | 862 } |
863 | 863 |
864 // Sets whether or not to accept first responder status. | 864 // Sets whether or not to accept first responder status. |
865 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { | 865 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { |
866 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; | 866 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; |
867 } | 867 } |
868 | 868 |
869 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) { | 869 void RenderWidgetHostViewMac::ForwardMouseEvent(const WebMouseEvent& event) { |
870 if (render_widget_host_) | 870 if (render_widget_host_) |
(...skipping 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3300 if (!string) return NO; | 3300 if (!string) return NO; |
3301 | 3301 |
3302 // If the user is currently using an IME, confirm the IME input, | 3302 // If the user is currently using an IME, confirm the IME input, |
3303 // and then insert the text from the service, the same as TextEdit and Safari. | 3303 // and then insert the text from the service, the same as TextEdit and Safari. |
3304 [self confirmComposition]; | 3304 [self confirmComposition]; |
3305 [self insertText:string]; | 3305 [self insertText:string]; |
3306 return YES; | 3306 return YES; |
3307 } | 3307 } |
3308 | 3308 |
3309 @end | 3309 @end |
OLD | NEW |