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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 using gfx::SkIRectToRect; | 93 using gfx::SkIRectToRect; |
94 | 94 |
95 using blink::WebScreenInfo; | 95 using blink::WebScreenInfo; |
96 using blink::WebTouchEvent; | 96 using blink::WebTouchEvent; |
97 | 97 |
98 namespace content { | 98 namespace content { |
99 | 99 |
100 namespace { | 100 namespace { |
101 | 101 |
102 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, | 102 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, |
103 unsigned sync_point, bool lost_resource) { | 103 uint32 sync_point, |
| 104 bool lost_resource) { |
104 // NOTE: shared_memory will get released when we go out of scope. | 105 // NOTE: shared_memory will get released when we go out of scope. |
105 } | 106 } |
106 | 107 |
107 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting | 108 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting |
108 // the border of the view, in order to get valid movement information. However, | 109 // the border of the view, in order to get valid movement information. However, |
109 // forcing the cursor back to the center of the view after each mouse move | 110 // forcing the cursor back to the center of the view after each mouse move |
110 // doesn't work well. It reduces the frequency of useful mouse move messages | 111 // doesn't work well. It reduces the frequency of useful mouse move messages |
111 // significantly. Therefore, we move the cursor to the center of the view only | 112 // significantly. Therefore, we move the cursor to the center of the view only |
112 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width | 113 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width |
113 // of the border area, in percentage of the corresponding dimension. | 114 // of the border area, in percentage of the corresponding dimension. |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 &RenderWidgetHostViewAura:: | 1104 &RenderWidgetHostViewAura:: |
1104 CopyFromCompositingSurfaceHasResultForVideo, | 1105 CopyFromCompositingSurfaceHasResultForVideo, |
1105 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. | 1106 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. |
1106 subscriber_texture, | 1107 subscriber_texture, |
1107 target, | 1108 target, |
1108 callback)); | 1109 callback)); |
1109 gfx::Rect src_subrect_in_pixel = | 1110 gfx::Rect src_subrect_in_pixel = |
1110 ConvertRectToPixel(current_device_scale_factor_, src_subrect); | 1111 ConvertRectToPixel(current_device_scale_factor_, src_subrect); |
1111 request->set_area(src_subrect_in_pixel); | 1112 request->set_area(src_subrect_in_pixel); |
1112 if (subscriber_texture.get()) { | 1113 if (subscriber_texture.get()) { |
1113 request->SetTextureMailbox(cc::TextureMailbox( | 1114 request->SetTextureMailbox( |
1114 subscriber_texture->mailbox(), subscriber_texture->sync_point())); | 1115 cc::TextureMailbox(subscriber_texture->mailbox(), |
| 1116 subscriber_texture->target(), |
| 1117 subscriber_texture->sync_point())); |
1115 } | 1118 } |
1116 RequestCopyOfOutput(request.Pass()); | 1119 RequestCopyOfOutput(request.Pass()); |
1117 } | 1120 } |
1118 | 1121 |
1119 bool RenderWidgetHostViewAura::CanCopyToBitmap() const { | 1122 bool RenderWidgetHostViewAura::CanCopyToBitmap() const { |
1120 return GetCompositor() && window_->layer()->has_external_content(); | 1123 return GetCompositor() && window_->layer()->has_external_content(); |
1121 } | 1124 } |
1122 | 1125 |
1123 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { | 1126 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { |
1124 return GetCompositor() && | 1127 return GetCompositor() && |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 cc::TextureMailbox texture_mailbox; | 1861 cc::TextureMailbox texture_mailbox; |
1859 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 1862 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
1860 result->TakeTexture(&texture_mailbox, &release_callback); | 1863 result->TakeTexture(&texture_mailbox, &release_callback); |
1861 DCHECK(texture_mailbox.IsTexture()); | 1864 DCHECK(texture_mailbox.IsTexture()); |
1862 if (!texture_mailbox.IsTexture()) | 1865 if (!texture_mailbox.IsTexture()) |
1863 return; | 1866 return; |
1864 | 1867 |
1865 ignore_result(scoped_callback_runner.Release()); | 1868 ignore_result(scoped_callback_runner.Release()); |
1866 | 1869 |
1867 gl_helper->CropScaleReadbackAndCleanMailbox( | 1870 gl_helper->CropScaleReadbackAndCleanMailbox( |
1868 texture_mailbox.name(), | 1871 texture_mailbox.mailbox(), |
1869 texture_mailbox.sync_point(), | 1872 texture_mailbox.sync_point(), |
1870 result->size(), | 1873 result->size(), |
1871 gfx::Rect(result->size()), | 1874 gfx::Rect(result->size()), |
1872 dst_size_in_pixel, | 1875 dst_size_in_pixel, |
1873 pixels, | 1876 pixels, |
1874 base::Bind(&CopyFromCompositingSurfaceFinished, | 1877 base::Bind(&CopyFromCompositingSurfaceFinished, |
1875 callback, | 1878 callback, |
1876 base::Passed(&release_callback), | 1879 base::Passed(&release_callback), |
1877 base::Passed(&bitmap), | 1880 base::Passed(&bitmap), |
1878 base::Passed(&bitmap_pixels_lock))); | 1881 base::Passed(&bitmap_pixels_lock))); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2058 } | 2061 } |
2059 | 2062 |
2060 ignore_result(scoped_callback_runner.Release()); | 2063 ignore_result(scoped_callback_runner.Release()); |
2061 ignore_result(scoped_return_subscriber_texture.Release()); | 2064 ignore_result(scoped_return_subscriber_texture.Release()); |
2062 base::Callback<void(bool result)> finished_callback = base::Bind( | 2065 base::Callback<void(bool result)> finished_callback = base::Bind( |
2063 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo, | 2066 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo, |
2064 rwhva->AsWeakPtr(), | 2067 rwhva->AsWeakPtr(), |
2065 callback, | 2068 callback, |
2066 subscriber_texture, | 2069 subscriber_texture, |
2067 base::Passed(&release_callback)); | 2070 base::Passed(&release_callback)); |
2068 yuv_readback_pipeline->ReadbackYUV( | 2071 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(), |
2069 texture_mailbox.name(), | 2072 texture_mailbox.sync_point(), |
2070 texture_mailbox.sync_point(), | 2073 video_frame.get(), |
2071 video_frame.get(), | 2074 finished_callback); |
2072 finished_callback); | |
2073 } | 2075 } |
2074 | 2076 |
2075 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { | 2077 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { |
2076 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); | 2078 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); |
2077 } | 2079 } |
2078 | 2080 |
2079 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { | 2081 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { |
2080 #if defined(OS_WIN) | 2082 #if defined(OS_WIN) |
2081 // aura::Window::GetBoundsInScreen doesn't take non-client area into | 2083 // aura::Window::GetBoundsInScreen doesn't take non-client area into |
2082 // account. | 2084 // account. |
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3520 RenderWidgetHost* widget) { | 3522 RenderWidgetHost* widget) { |
3521 return new RenderWidgetHostViewAura(widget); | 3523 return new RenderWidgetHostViewAura(widget); |
3522 } | 3524 } |
3523 | 3525 |
3524 // static | 3526 // static |
3525 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3527 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3526 GetScreenInfoForWindow(results, NULL); | 3528 GetScreenInfoForWindow(results, NULL); |
3527 } | 3529 } |
3528 | 3530 |
3529 } // namespace content | 3531 } // namespace content |
OLD | NEW |