| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 using gfx::SkIRectToRect; | 90 using gfx::SkIRectToRect; |
| 91 | 91 |
| 92 using blink::WebScreenInfo; | 92 using blink::WebScreenInfo; |
| 93 using blink::WebTouchEvent; | 93 using blink::WebTouchEvent; |
| 94 | 94 |
| 95 namespace content { | 95 namespace content { |
| 96 | 96 |
| 97 namespace { | 97 namespace { |
| 98 | 98 |
| 99 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, | 99 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, |
| 100 unsigned sync_point, bool lost_resource) { | 100 uint32 sync_point, |
| 101 bool lost_resource) { |
| 101 // NOTE: shared_memory will get released when we go out of scope. | 102 // NOTE: shared_memory will get released when we go out of scope. |
| 102 } | 103 } |
| 103 | 104 |
| 104 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting | 105 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting |
| 105 // the border of the view, in order to get valid movement information. However, | 106 // the border of the view, in order to get valid movement information. However, |
| 106 // forcing the cursor back to the center of the view after each mouse move | 107 // forcing the cursor back to the center of the view after each mouse move |
| 107 // doesn't work well. It reduces the frequency of useful mouse move messages | 108 // doesn't work well. It reduces the frequency of useful mouse move messages |
| 108 // significantly. Therefore, we move the cursor to the center of the view only | 109 // significantly. Therefore, we move the cursor to the center of the view only |
| 109 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width | 110 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width |
| 110 // of the border area, in percentage of the corresponding dimension. | 111 // of the border area, in percentage of the corresponding dimension. |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 &RenderWidgetHostViewAura:: | 1101 &RenderWidgetHostViewAura:: |
| 1101 CopyFromCompositingSurfaceHasResultForVideo, | 1102 CopyFromCompositingSurfaceHasResultForVideo, |
| 1102 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. | 1103 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. |
| 1103 subscriber_texture, | 1104 subscriber_texture, |
| 1104 target, | 1105 target, |
| 1105 callback)); | 1106 callback)); |
| 1106 gfx::Rect src_subrect_in_pixel = | 1107 gfx::Rect src_subrect_in_pixel = |
| 1107 ConvertRectToPixel(current_device_scale_factor_, src_subrect); | 1108 ConvertRectToPixel(current_device_scale_factor_, src_subrect); |
| 1108 request->set_area(src_subrect_in_pixel); | 1109 request->set_area(src_subrect_in_pixel); |
| 1109 if (subscriber_texture) { | 1110 if (subscriber_texture) { |
| 1110 request->SetTextureMailbox(cc::TextureMailbox( | 1111 request->SetTextureMailbox( |
| 1111 subscriber_texture->mailbox(), subscriber_texture->sync_point())); | 1112 cc::TextureMailbox(subscriber_texture->mailbox(), |
| 1113 subscriber_texture->target(), |
| 1114 subscriber_texture->sync_point())); |
| 1112 } | 1115 } |
| 1113 window_->layer()->RequestCopyOfOutput(request.Pass()); | 1116 window_->layer()->RequestCopyOfOutput(request.Pass()); |
| 1114 } | 1117 } |
| 1115 | 1118 |
| 1116 bool RenderWidgetHostViewAura::CanCopyToBitmap() const { | 1119 bool RenderWidgetHostViewAura::CanCopyToBitmap() const { |
| 1117 return GetCompositor() && window_->layer()->has_external_content(); | 1120 return GetCompositor() && window_->layer()->has_external_content(); |
| 1118 } | 1121 } |
| 1119 | 1122 |
| 1120 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { | 1123 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { |
| 1121 return GetCompositor() && | 1124 return GetCompositor() && |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 cc::TextureMailbox texture_mailbox; | 1846 cc::TextureMailbox texture_mailbox; |
| 1844 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 1847 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
| 1845 result->TakeTexture(&texture_mailbox, &release_callback); | 1848 result->TakeTexture(&texture_mailbox, &release_callback); |
| 1846 DCHECK(texture_mailbox.IsTexture()); | 1849 DCHECK(texture_mailbox.IsTexture()); |
| 1847 if (!texture_mailbox.IsTexture()) | 1850 if (!texture_mailbox.IsTexture()) |
| 1848 return; | 1851 return; |
| 1849 | 1852 |
| 1850 ignore_result(scoped_callback_runner.Release()); | 1853 ignore_result(scoped_callback_runner.Release()); |
| 1851 | 1854 |
| 1852 gl_helper->CropScaleReadbackAndCleanMailbox( | 1855 gl_helper->CropScaleReadbackAndCleanMailbox( |
| 1853 texture_mailbox.name(), | 1856 texture_mailbox.mailbox(), |
| 1854 texture_mailbox.sync_point(), | 1857 texture_mailbox.sync_point(), |
| 1855 result->size(), | 1858 result->size(), |
| 1856 gfx::Rect(result->size()), | 1859 gfx::Rect(result->size()), |
| 1857 dst_size_in_pixel, | 1860 dst_size_in_pixel, |
| 1858 pixels, | 1861 pixels, |
| 1859 base::Bind(&CopyFromCompositingSurfaceFinished, | 1862 base::Bind(&CopyFromCompositingSurfaceFinished, |
| 1860 callback, | 1863 callback, |
| 1861 base::Passed(&release_callback), | 1864 base::Passed(&release_callback), |
| 1862 base::Passed(&bitmap), | 1865 base::Passed(&bitmap), |
| 1863 base::Passed(&bitmap_pixels_lock))); | 1866 base::Passed(&bitmap_pixels_lock))); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 | 1903 |
| 1901 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); | 1904 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); |
| 1902 uint32 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0; | 1905 uint32 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0; |
| 1903 if (release_callback) { | 1906 if (release_callback) { |
| 1904 DCHECK(!subscriber_texture); | 1907 DCHECK(!subscriber_texture); |
| 1905 release_callback->Run(sync_point, false); | 1908 release_callback->Run(sync_point, false); |
| 1906 } else { | 1909 } else { |
| 1907 // If there's no release callback, then the texture is from | 1910 // If there's no release callback, then the texture is from |
| 1908 // idle_frame_subscriber_textures_ and we can put it back there. | 1911 // idle_frame_subscriber_textures_ and we can put it back there. |
| 1909 DCHECK(subscriber_texture); | 1912 DCHECK(subscriber_texture); |
| 1910 subscriber_texture->UpdateSyncPoint(sync_point); | 1913 subscriber_texture->set_sync_point(sync_point); |
| 1911 if (rwhva && rwhva->frame_subscriber_ && subscriber_texture->texture_id()) | 1914 if (rwhva && rwhva->frame_subscriber_ && subscriber_texture->texture_id()) |
| 1912 rwhva->idle_frame_subscriber_textures_.push_back(subscriber_texture); | 1915 rwhva->idle_frame_subscriber_textures_.push_back(subscriber_texture); |
| 1913 subscriber_texture = NULL; | 1916 subscriber_texture = NULL; |
| 1914 } | 1917 } |
| 1915 } | 1918 } |
| 1916 | 1919 |
| 1917 // static | 1920 // static |
| 1918 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo( | 1921 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo( |
| 1919 base::WeakPtr<RenderWidgetHostViewAura> rwhva, | 1922 base::WeakPtr<RenderWidgetHostViewAura> rwhva, |
| 1920 scoped_refptr<OwnedMailbox> subscriber_texture, | 1923 scoped_refptr<OwnedMailbox> subscriber_texture, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get(); | 2028 yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get(); |
| 2026 } | 2029 } |
| 2027 | 2030 |
| 2028 ignore_result(scoped_callback_runner.Release()); | 2031 ignore_result(scoped_callback_runner.Release()); |
| 2029 base::Callback<void(bool result)> finished_callback = base::Bind( | 2032 base::Callback<void(bool result)> finished_callback = base::Bind( |
| 2030 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo, | 2033 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo, |
| 2031 rwhva->AsWeakPtr(), | 2034 rwhva->AsWeakPtr(), |
| 2032 callback, | 2035 callback, |
| 2033 subscriber_texture, | 2036 subscriber_texture, |
| 2034 base::Passed(&release_callback)); | 2037 base::Passed(&release_callback)); |
| 2035 yuv_readback_pipeline->ReadbackYUV( | 2038 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(), |
| 2036 texture_mailbox.name(), | 2039 texture_mailbox.sync_point(), |
| 2037 texture_mailbox.sync_point(), | 2040 video_frame.get(), |
| 2038 video_frame.get(), | 2041 finished_callback); |
| 2039 finished_callback); | |
| 2040 } | 2042 } |
| 2041 | 2043 |
| 2042 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { | 2044 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { |
| 2043 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); | 2045 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); |
| 2044 } | 2046 } |
| 2045 | 2047 |
| 2046 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { | 2048 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { |
| 2047 #if defined(OS_WIN) | 2049 #if defined(OS_WIN) |
| 2048 // aura::Window::GetBoundsInScreen doesn't take non-client area into | 2050 // aura::Window::GetBoundsInScreen doesn't take non-client area into |
| 2049 // account. | 2051 // account. |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3452 RenderWidgetHost* widget) { | 3454 RenderWidgetHost* widget) { |
| 3453 return new RenderWidgetHostViewAura(widget); | 3455 return new RenderWidgetHostViewAura(widget); |
| 3454 } | 3456 } |
| 3455 | 3457 |
| 3456 // static | 3458 // static |
| 3457 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3459 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3458 GetScreenInfoForWindow(results, NULL); | 3460 GetScreenInfoForWindow(results, NULL); |
| 3459 } | 3461 } |
| 3460 | 3462 |
| 3461 } // namespace content | 3463 } // namespace content |
| OLD | NEW |