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

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

Issue 148003006: Use gpu::Mailbox instead of std:string in IPCs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed typo Created 6 years, 10 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 int renderer_host_id, 320 int renderer_host_id,
321 const gpu::Mailbox& received_mailbox, 321 const gpu::Mailbox& received_mailbox,
322 const gfx::Size& received_size, 322 const gfx::Size& received_size,
323 bool skip_frame, 323 bool skip_frame,
324 const scoped_refptr<ui::Texture>& texture_to_produce) { 324 const scoped_refptr<ui::Texture>& texture_to_produce) {
325 cc::CompositorFrameAck ack; 325 cc::CompositorFrameAck ack;
326 ack.gl_frame_data.reset(new cc::GLFrameData()); 326 ack.gl_frame_data.reset(new cc::GLFrameData());
327 DCHECK(!texture_to_produce.get() || !skip_frame); 327 DCHECK(!texture_to_produce.get() || !skip_frame);
328 if (texture_to_produce.get()) { 328 if (texture_to_produce.get()) {
329 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); 329 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
330 std::string mailbox_name = texture_to_produce->Produce(); 330 ack.gl_frame_data->mailbox = texture_to_produce->Produce();
331 std::copy(mailbox_name.data(),
332 mailbox_name.data() + mailbox_name.length(),
333 reinterpret_cast<char*>(ack.gl_frame_data->mailbox.name));
334 ack.gl_frame_data->size = texture_to_produce->size(); 331 ack.gl_frame_data->size = texture_to_produce->size();
335 ack.gl_frame_data->sync_point = 332 ack.gl_frame_data->sync_point =
336 gl_helper ? gl_helper->InsertSyncPoint() : 0; 333 gl_helper ? gl_helper->InsertSyncPoint() : 0;
337 } else if (skip_frame) { 334 } else if (skip_frame) {
338 // Skip the frame, i.e. tell the producer to reuse the same buffer that 335 // Skip the frame, i.e. tell the producer to reuse the same buffer that
339 // we just received. 336 // we just received.
340 ack.gl_frame_data->size = received_size; 337 ack.gl_frame_data->size = received_size;
341 ack.gl_frame_data->mailbox = received_mailbox; 338 ack.gl_frame_data->mailbox = received_mailbox;
342 } 339 }
343 340
344 RenderWidgetHostImpl::SendSwapCompositorFrameAck( 341 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
345 route_id, output_surface_id, renderer_host_id, ack); 342 route_id, output_surface_id, renderer_host_id, ack);
346 } 343 }
347 344
348 void AcknowledgeBufferForGpu( 345 void AcknowledgeBufferForGpu(
349 int32 route_id, 346 int32 route_id,
350 int gpu_host_id, 347 int gpu_host_id,
351 const std::string& received_mailbox, 348 const gpu::Mailbox& received_mailbox,
352 bool skip_frame, 349 bool skip_frame,
353 const scoped_refptr<ui::Texture>& texture_to_produce) { 350 const scoped_refptr<ui::Texture>& texture_to_produce) {
354 AcceleratedSurfaceMsg_BufferPresented_Params ack; 351 AcceleratedSurfaceMsg_BufferPresented_Params ack;
355 uint32 sync_point = 0; 352 uint32 sync_point = 0;
356 DCHECK(!texture_to_produce.get() || !skip_frame); 353 DCHECK(!texture_to_produce.get() || !skip_frame);
357 if (texture_to_produce.get()) { 354 if (texture_to_produce.get()) {
358 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); 355 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
359 ack.mailbox_name = texture_to_produce->Produce(); 356 ack.mailbox = texture_to_produce->Produce();
360 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0; 357 sync_point = gl_helper ? gl_helper->InsertSyncPoint() : 0;
361 } else if (skip_frame) { 358 } else if (skip_frame) {
362 ack.mailbox_name = received_mailbox; 359 ack.mailbox = received_mailbox;
363 ack.sync_point = 0; 360 ack.sync_point = 0;
364 } 361 }
365 362
366 ack.sync_point = sync_point; 363 ack.sync_point = sync_point;
367 RenderWidgetHostImpl::AcknowledgeBufferPresent( 364 RenderWidgetHostImpl::AcknowledgeBufferPresent(
368 route_id, gpu_host_id, ack); 365 route_id, gpu_host_id, ack);
369 } 366 }
370 367
371 } // namespace 368 } // namespace
372 369
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 resize_lock_.reset(); 1292 resize_lock_.reset();
1296 host_->WasResized(); 1293 host_->WasResized();
1297 software_frame_manager_->DiscardCurrentFrame(); 1294 software_frame_manager_->DiscardCurrentFrame();
1298 } 1295 }
1299 } 1296 }
1300 1297
1301 bool RenderWidgetHostViewAura::SwapBuffersPrepare( 1298 bool RenderWidgetHostViewAura::SwapBuffersPrepare(
1302 const gfx::Rect& surface_rect, 1299 const gfx::Rect& surface_rect,
1303 float surface_scale_factor, 1300 float surface_scale_factor,
1304 const gfx::Rect& damage_rect, 1301 const gfx::Rect& damage_rect,
1305 const std::string& mailbox_name, 1302 const gpu::Mailbox& mailbox,
1306 const BufferPresentedCallback& ack_callback) { 1303 const BufferPresentedCallback& ack_callback) {
1307 if (last_swapped_surface_size_ != surface_rect.size()) { 1304 if (last_swapped_surface_size_ != surface_rect.size()) {
1308 // The surface could have shrunk since we skipped an update, in which 1305 // The surface could have shrunk since we skipped an update, in which
1309 // case we can expect a full update. 1306 // case we can expect a full update.
1310 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; 1307 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect";
1311 skipped_damage_.setEmpty(); 1308 skipped_damage_.setEmpty();
1312 last_swapped_surface_size_ = surface_rect.size(); 1309 last_swapped_surface_size_ = surface_rect.size();
1313 last_swapped_surface_scale_factor_ = surface_scale_factor; 1310 last_swapped_surface_scale_factor_ = surface_scale_factor;
1314 } 1311 }
1315 1312
1316 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor, 1313 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor,
1317 surface_rect.size())) || 1314 surface_rect.size())) ||
1318 mailbox_name.empty()) { 1315 mailbox.IsZero()) {
1319 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); 1316 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op);
1320 ack_callback.Run(true, scoped_refptr<ui::Texture>()); 1317 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1321 return false; 1318 return false;
1322 } 1319 }
1323 1320
1324 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1321 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1325 current_surface_ = 1322 current_surface_ =
1326 factory->CreateTransportClient(surface_scale_factor); 1323 factory->CreateTransportClient(surface_scale_factor);
1327 if (!current_surface_.get()) { 1324 if (!current_surface_.get()) {
1328 LOG(ERROR) << "Failed to create ImageTransport texture"; 1325 LOG(ERROR) << "Failed to create ImageTransport texture";
1329 ack_callback.Run(true, scoped_refptr<ui::Texture>()); 1326 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1330 return false; 1327 return false;
1331 } 1328 }
1332 1329
1333 current_surface_->Consume(mailbox_name, surface_rect.size()); 1330 current_surface_->Consume(mailbox, surface_rect.size());
1334 released_front_lock_ = NULL; 1331 released_front_lock_ = NULL;
1335 UpdateExternalTexture(); 1332 UpdateExternalTexture();
1336 1333
1337 return true; 1334 return true;
1338 } 1335 }
1339 1336
1340 void RenderWidgetHostViewAura::SwapBuffersCompleted( 1337 void RenderWidgetHostViewAura::SwapBuffersCompleted(
1341 const BufferPresentedCallback& ack_callback, 1338 const BufferPresentedCallback& ack_callback,
1342 const scoped_refptr<ui::Texture>& texture_to_return) { 1339 const scoped_refptr<ui::Texture>& texture_to_return) {
1343 ui::Compositor* compositor = GetCompositor(); 1340 ui::Compositor* compositor = GetCompositor();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 } 1386 }
1390 #endif 1387 #endif
1391 1388
1392 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 1389 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
1393 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 1390 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
1394 int gpu_host_id) { 1391 int gpu_host_id) {
1395 BufferPresentedCallback ack_callback = base::Bind( 1392 BufferPresentedCallback ack_callback = base::Bind(
1396 &AcknowledgeBufferForGpu, 1393 &AcknowledgeBufferForGpu,
1397 params_in_pixel.route_id, 1394 params_in_pixel.route_id,
1398 gpu_host_id, 1395 gpu_host_id,
1399 params_in_pixel.mailbox_name); 1396 params_in_pixel.mailbox);
1400 BuffersSwapped(params_in_pixel.size, 1397 BuffersSwapped(params_in_pixel.size,
1401 gfx::Rect(params_in_pixel.size), 1398 gfx::Rect(params_in_pixel.size),
1402 params_in_pixel.scale_factor, 1399 params_in_pixel.scale_factor,
1403 params_in_pixel.mailbox_name, 1400 params_in_pixel.mailbox,
1404 params_in_pixel.latency_info, 1401 params_in_pixel.latency_info,
1405 ack_callback); 1402 ack_callback);
1406 } 1403 }
1407 1404
1408 void RenderWidgetHostViewAura::SwapDelegatedFrame( 1405 void RenderWidgetHostViewAura::SwapDelegatedFrame(
1409 uint32 output_surface_id, 1406 uint32 output_surface_id,
1410 scoped_ptr<cc::DelegatedFrameData> frame_data, 1407 scoped_ptr<cc::DelegatedFrameData> frame_data,
1411 float frame_device_scale_factor, 1408 float frame_device_scale_factor,
1412 const std::vector<ui::LatencyInfo>& latency_info) { 1409 const std::vector<ui::LatencyInfo>& latency_info) {
1413 DCHECK_NE(0u, frame_data->render_pass_list.size()); 1410 DCHECK_NE(0u, frame_data->render_pass_list.size());
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 1681
1685 if (!frame->gl_frame_data->sync_point) { 1682 if (!frame->gl_frame_data->sync_point) {
1686 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame..."; 1683 LOG(ERROR) << "CompositorFrame without sync point. Skipping frame...";
1687 ack_callback.Run(true, scoped_refptr<ui::Texture>()); 1684 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1688 return; 1685 return;
1689 } 1686 }
1690 1687
1691 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper(); 1688 GLHelper* gl_helper = ImageTransportFactory::GetInstance()->GetGLHelper();
1692 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point); 1689 gl_helper->WaitSyncPoint(frame->gl_frame_data->sync_point);
1693 1690
1694 std::string mailbox_name(
1695 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name),
1696 sizeof(frame->gl_frame_data->mailbox.name));
1697 BuffersSwapped(frame->gl_frame_data->size, 1691 BuffersSwapped(frame->gl_frame_data->size,
1698 frame->gl_frame_data->sub_buffer_rect, 1692 frame->gl_frame_data->sub_buffer_rect,
1699 frame->metadata.device_scale_factor, 1693 frame->metadata.device_scale_factor,
1700 mailbox_name, 1694 frame->gl_frame_data->mailbox,
1701 frame->metadata.latency_info, 1695 frame->metadata.latency_info,
1702 ack_callback); 1696 ack_callback);
1703 } 1697 }
1704 1698
1705 #if defined(OS_WIN) 1699 #if defined(OS_WIN)
1706 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1700 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1707 gfx::NativeViewAccessible accessible_parent) { 1701 gfx::NativeViewAccessible accessible_parent) {
1708 if (GetBrowserAccessibilityManager()) { 1702 if (GetBrowserAccessibilityManager()) {
1709 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin() 1703 GetBrowserAccessibilityManager()->ToBrowserAccessibilityManagerWin()
1710 ->set_parent_iaccessible(accessible_parent); 1704 ->set_parent_iaccessible(accessible_parent);
1711 } 1705 }
1712 } 1706 }
1713 1707
1714 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1708 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1715 const { 1709 const {
1716 if (legacy_render_widget_host_HWND_) { 1710 if (legacy_render_widget_host_HWND_) {
1717 return reinterpret_cast<gfx::NativeViewId>( 1711 return reinterpret_cast<gfx::NativeViewId>(
1718 legacy_render_widget_host_HWND_->hwnd()); 1712 legacy_render_widget_host_HWND_->hwnd());
1719 } 1713 }
1720 return NULL; 1714 return NULL;
1721 } 1715 }
1722 #endif 1716 #endif
1723 1717
1724 void RenderWidgetHostViewAura::BuffersSwapped( 1718 void RenderWidgetHostViewAura::BuffersSwapped(
1725 const gfx::Size& surface_size, 1719 const gfx::Size& surface_size,
1726 const gfx::Rect& damage_rect, 1720 const gfx::Rect& damage_rect,
1727 float surface_scale_factor, 1721 float surface_scale_factor,
1728 const std::string& mailbox_name, 1722 const gpu::Mailbox& mailbox,
1729 const std::vector<ui::LatencyInfo>& latency_info, 1723 const std::vector<ui::LatencyInfo>& latency_info,
1730 const BufferPresentedCallback& ack_callback) { 1724 const BufferPresentedCallback& ack_callback) {
1731 scoped_refptr<ui::Texture> previous_texture(current_surface_); 1725 scoped_refptr<ui::Texture> previous_texture(current_surface_);
1732 const gfx::Rect surface_rect = gfx::Rect(surface_size); 1726 const gfx::Rect surface_rect = gfx::Rect(surface_size);
1733 software_frame_manager_->DiscardCurrentFrame(); 1727 software_frame_manager_->DiscardCurrentFrame();
1734 1728
1735 if (!SwapBuffersPrepare(surface_rect, 1729 if (!SwapBuffersPrepare(surface_rect,
1736 surface_scale_factor, 1730 surface_scale_factor,
1737 damage_rect, 1731 damage_rect,
1738 mailbox_name, 1732 mailbox,
1739 ack_callback)) { 1733 ack_callback)) {
1740 return; 1734 return;
1741 } 1735 }
1742 1736
1743 SkRegion damage(RectToSkIRect(damage_rect)); 1737 SkRegion damage(RectToSkIRect(damage_rect));
1744 if (!skipped_damage_.isEmpty()) { 1738 if (!skipped_damage_.isEmpty()) {
1745 damage.op(skipped_damage_, SkRegion::kUnion_Op); 1739 damage.op(skipped_damage_, SkRegion::kUnion_Op);
1746 skipped_damage_.setEmpty(); 1740 skipped_damage_.setEmpty();
1747 } 1741 }
1748 1742
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 1789 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
1796 int gpu_host_id) { 1790 int gpu_host_id) {
1797 gfx::Rect damage_rect(params_in_pixel.x, 1791 gfx::Rect damage_rect(params_in_pixel.x,
1798 params_in_pixel.y, 1792 params_in_pixel.y,
1799 params_in_pixel.width, 1793 params_in_pixel.width,
1800 params_in_pixel.height); 1794 params_in_pixel.height);
1801 BufferPresentedCallback ack_callback = 1795 BufferPresentedCallback ack_callback =
1802 base::Bind(&AcknowledgeBufferForGpu, 1796 base::Bind(&AcknowledgeBufferForGpu,
1803 params_in_pixel.route_id, 1797 params_in_pixel.route_id,
1804 gpu_host_id, 1798 gpu_host_id,
1805 params_in_pixel.mailbox_name); 1799 params_in_pixel.mailbox);
1806 BuffersSwapped(params_in_pixel.surface_size, 1800 BuffersSwapped(params_in_pixel.surface_size,
1807 damage_rect, 1801 damage_rect,
1808 params_in_pixel.surface_scale_factor, 1802 params_in_pixel.surface_scale_factor,
1809 params_in_pixel.mailbox_name, 1803 params_in_pixel.mailbox,
1810 params_in_pixel.latency_info, 1804 params_in_pixel.latency_info,
1811 ack_callback); 1805 ack_callback);
1812 } 1806 }
1813 1807
1814 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() { 1808 void RenderWidgetHostViewAura::AcceleratedSurfaceSuspend() {
1815 } 1809 }
1816 1810
1817 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { 1811 void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() {
1818 // This really tells us to release the frontbuffer. 1812 // This really tells us to release the frontbuffer.
1819 if (current_surface_.get()) { 1813 if (current_surface_.get()) {
(...skipping 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
3608 RenderWidgetHost* widget) { 3602 RenderWidgetHost* widget) {
3609 return new RenderWidgetHostViewAura(widget); 3603 return new RenderWidgetHostViewAura(widget);
3610 } 3604 }
3611 3605
3612 // static 3606 // static
3613 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3607 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3614 GetScreenInfoForWindow(results, NULL); 3608 GetScreenInfoForWindow(results, NULL);
3615 } 3609 }
3616 3610
3617 } // namespace content 3611 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698