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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 105743004: Add gpu::MailboxHolder to hold state for a gpu::Mailbox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: c301e01d Rebase. Created 6 years, 11 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
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 using gfx::SkIRectToRect; 91 using gfx::SkIRectToRect;
92 92
93 using blink::WebScreenInfo; 93 using blink::WebScreenInfo;
94 using blink::WebTouchEvent; 94 using blink::WebTouchEvent;
95 95
96 namespace content { 96 namespace content {
97 97
98 namespace { 98 namespace {
99 99
100 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, 100 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory,
101 unsigned sync_point, bool lost_resource) { 101 uint32 sync_point,
102 bool lost_resource) {
102 // NOTE: shared_memory will get released when we go out of scope. 103 // NOTE: shared_memory will get released when we go out of scope.
103 } 104 }
104 105
105 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting 106 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting
106 // the border of the view, in order to get valid movement information. However, 107 // the border of the view, in order to get valid movement information. However,
107 // forcing the cursor back to the center of the view after each mouse move 108 // forcing the cursor back to the center of the view after each mouse move
108 // doesn't work well. It reduces the frequency of useful mouse move messages 109 // doesn't work well. It reduces the frequency of useful mouse move messages
109 // significantly. Therefore, we move the cursor to the center of the view only 110 // significantly. Therefore, we move the cursor to the center of the view only
110 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width 111 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width
111 // of the border area, in percentage of the corresponding dimension. 112 // of the border area, in percentage of the corresponding dimension.
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 &RenderWidgetHostViewAura:: 1083 &RenderWidgetHostViewAura::
1083 CopyFromCompositingSurfaceHasResultForVideo, 1084 CopyFromCompositingSurfaceHasResultForVideo,
1084 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. 1085 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class.
1085 subscriber_texture, 1086 subscriber_texture,
1086 target, 1087 target,
1087 callback)); 1088 callback));
1088 gfx::Rect src_subrect_in_pixel = 1089 gfx::Rect src_subrect_in_pixel =
1089 ConvertRectToPixel(current_device_scale_factor_, src_subrect); 1090 ConvertRectToPixel(current_device_scale_factor_, src_subrect);
1090 request->set_area(src_subrect_in_pixel); 1091 request->set_area(src_subrect_in_pixel);
1091 if (subscriber_texture) { 1092 if (subscriber_texture) {
1092 request->SetTextureMailbox(cc::TextureMailbox( 1093 request->SetTextureMailbox(
1093 subscriber_texture->mailbox(), subscriber_texture->sync_point())); 1094 cc::TextureMailbox(subscriber_texture->mailbox(),
1095 subscriber_texture->target(),
1096 subscriber_texture->sync_point()));
1094 } 1097 }
1095 window_->layer()->RequestCopyOfOutput(request.Pass()); 1098 window_->layer()->RequestCopyOfOutput(request.Pass());
1096 } 1099 }
1097 1100
1098 bool RenderWidgetHostViewAura::CanCopyToBitmap() const { 1101 bool RenderWidgetHostViewAura::CanCopyToBitmap() const {
1099 return GetCompositor() && window_->layer()->has_external_content(); 1102 return GetCompositor() && window_->layer()->has_external_content();
1100 } 1103 }
1101 1104
1102 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { 1105 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const {
1103 return GetCompositor() && 1106 return GetCompositor() &&
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 cc::TextureMailbox texture_mailbox; 1837 cc::TextureMailbox texture_mailbox;
1835 scoped_ptr<cc::SingleReleaseCallback> release_callback; 1838 scoped_ptr<cc::SingleReleaseCallback> release_callback;
1836 result->TakeTexture(&texture_mailbox, &release_callback); 1839 result->TakeTexture(&texture_mailbox, &release_callback);
1837 DCHECK(texture_mailbox.IsTexture()); 1840 DCHECK(texture_mailbox.IsTexture());
1838 if (!texture_mailbox.IsTexture()) 1841 if (!texture_mailbox.IsTexture())
1839 return; 1842 return;
1840 1843
1841 ignore_result(scoped_callback_runner.Release()); 1844 ignore_result(scoped_callback_runner.Release());
1842 1845
1843 gl_helper->CropScaleReadbackAndCleanMailbox( 1846 gl_helper->CropScaleReadbackAndCleanMailbox(
1844 texture_mailbox.name(), 1847 texture_mailbox.mailbox(),
1845 texture_mailbox.sync_point(), 1848 texture_mailbox.sync_point(),
1846 result->size(), 1849 result->size(),
1847 gfx::Rect(result->size()), 1850 gfx::Rect(result->size()),
1848 dst_size_in_pixel, 1851 dst_size_in_pixel,
1849 pixels, 1852 pixels,
1850 base::Bind(&CopyFromCompositingSurfaceFinished, 1853 base::Bind(&CopyFromCompositingSurfaceFinished,
1851 callback, 1854 callback,
1852 base::Passed(&release_callback), 1855 base::Passed(&release_callback),
1853 base::Passed(&bitmap), 1856 base::Passed(&bitmap),
1854 base::Passed(&bitmap_pixels_lock))); 1857 base::Passed(&bitmap_pixels_lock)));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 1894
1892 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); 1895 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
1893 uint32 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0; 1896 uint32 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0;
1894 if (release_callback) { 1897 if (release_callback) {
1895 DCHECK(!subscriber_texture); 1898 DCHECK(!subscriber_texture);
1896 release_callback->Run(sync_point, false); 1899 release_callback->Run(sync_point, false);
1897 } else { 1900 } else {
1898 // If there's no release callback, then the texture is from 1901 // If there's no release callback, then the texture is from
1899 // idle_frame_subscriber_textures_ and we can put it back there. 1902 // idle_frame_subscriber_textures_ and we can put it back there.
1900 DCHECK(subscriber_texture); 1903 DCHECK(subscriber_texture);
1901 subscriber_texture->UpdateSyncPoint(sync_point); 1904 subscriber_texture->set_sync_point(sync_point);
1902 if (rwhva && rwhva->frame_subscriber_ && subscriber_texture->texture_id()) 1905 if (rwhva && rwhva->frame_subscriber_ && subscriber_texture->texture_id())
1903 rwhva->idle_frame_subscriber_textures_.push_back(subscriber_texture); 1906 rwhva->idle_frame_subscriber_textures_.push_back(subscriber_texture);
1904 subscriber_texture = NULL; 1907 subscriber_texture = NULL;
1905 } 1908 }
1906 } 1909 }
1907 1910
1908 // static 1911 // static
1909 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo( 1912 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo(
1910 base::WeakPtr<RenderWidgetHostViewAura> rwhva, 1913 base::WeakPtr<RenderWidgetHostViewAura> rwhva,
1911 scoped_refptr<OwnedMailbox> subscriber_texture, 1914 scoped_refptr<OwnedMailbox> subscriber_texture,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get(); 2019 yuv_readback_pipeline = rwhva->yuv_readback_pipeline_.get();
2017 } 2020 }
2018 2021
2019 ignore_result(scoped_callback_runner.Release()); 2022 ignore_result(scoped_callback_runner.Release());
2020 base::Callback<void(bool result)> finished_callback = base::Bind( 2023 base::Callback<void(bool result)> finished_callback = base::Bind(
2021 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo, 2024 &RenderWidgetHostViewAura::CopyFromCompositingSurfaceFinishedForVideo,
2022 rwhva->AsWeakPtr(), 2025 rwhva->AsWeakPtr(),
2023 callback, 2026 callback,
2024 subscriber_texture, 2027 subscriber_texture,
2025 base::Passed(&release_callback)); 2028 base::Passed(&release_callback));
2026 yuv_readback_pipeline->ReadbackYUV( 2029 yuv_readback_pipeline->ReadbackYUV(texture_mailbox.mailbox(),
2027 texture_mailbox.name(), 2030 texture_mailbox.sync_point(),
2028 texture_mailbox.sync_point(), 2031 video_frame.get(),
2029 video_frame.get(), 2032 finished_callback);
2030 finished_callback);
2031 } 2033 }
2032 2034
2033 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { 2035 void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) {
2034 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); 2036 GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL);
2035 } 2037 }
2036 2038
2037 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { 2039 gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
2038 #if defined(OS_WIN) 2040 #if defined(OS_WIN)
2039 // aura::Window::GetBoundsInScreen doesn't take non-client area into 2041 // aura::Window::GetBoundsInScreen doesn't take non-client area into
2040 // account. 2042 // account.
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
3475 RenderWidgetHost* widget) { 3477 RenderWidgetHost* widget) {
3476 return new RenderWidgetHostViewAura(widget); 3478 return new RenderWidgetHostViewAura(widget);
3477 } 3479 }
3478 3480
3479 // static 3481 // static
3480 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3482 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3481 GetScreenInfoForWindow(results, NULL); 3483 GetScreenInfoForWindow(results, NULL);
3482 } 3484 }
3483 3485
3484 } // namespace content 3486 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698