| 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/image_transport_factory.h" | 5 #include "content/browser/renderer_host/image_transport_factory.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "cc/output/compositor_frame.h" |
| 17 #include "cc/output/output_surface.h" | 18 #include "cc/output/output_surface.h" |
| 18 #include "cc/output/output_surface_client.h" | 19 #include "cc/output/output_surface_client.h" |
| 19 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 20 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 20 #include "content/browser/gpu/gpu_data_manager_impl.h" | 21 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 21 #include "content/browser/gpu/gpu_process_host.h" | 22 #include "content/browser/gpu/gpu_process_host.h" |
| 22 #include "content/browser/gpu/gpu_surface_tracker.h" | 23 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 23 #include "content/common/gpu/client/context_provider_command_buffer.h" | 24 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 24 #include "content/common/gpu/client/gl_helper.h" | 25 #include "content/common/gpu/client/gl_helper.h" |
| 25 #include "content/common/gpu/client/gpu_channel_host.h" | 26 #include "content/common/gpu/client/gpu_channel_host.h" |
| 26 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 27 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 base::Bind(&ui::Compositor::OnUpdateVSyncParameters, | 533 base::Bind(&ui::Compositor::OnUpdateVSyncParameters, |
| 533 compositor_, timebase, interval)); | 534 compositor_, timebase, interval)); |
| 534 } | 535 } |
| 535 | 536 |
| 536 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE { | 537 virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE { |
| 537 OutputSurface::Reshape(size, scale_factor); | 538 OutputSurface::Reshape(size, scale_factor); |
| 538 if (reflector_.get()) | 539 if (reflector_.get()) |
| 539 reflector_->OnReshape(size); | 540 reflector_->OnReshape(size); |
| 540 } | 541 } |
| 541 | 542 |
| 542 virtual void SwapBuffers(const ui::LatencyInfo& latency_info) OVERRIDE { | 543 virtual void SwapBuffers(cc::CompositorFrame* frame) OVERRIDE { |
| 544 DCHECK(frame->gl_frame_data); |
| 545 |
| 543 WebGraphicsContext3DCommandBufferImpl* command_buffer = | 546 WebGraphicsContext3DCommandBufferImpl* command_buffer = |
| 544 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); | 547 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); |
| 545 CommandBufferProxyImpl* command_buffer_proxy = | 548 CommandBufferProxyImpl* command_buffer_proxy = |
| 546 command_buffer->GetCommandBufferProxy(); | 549 command_buffer->GetCommandBufferProxy(); |
| 547 DCHECK(command_buffer_proxy); | 550 DCHECK(command_buffer_proxy); |
| 548 context3d()->shallowFlushCHROMIUM(); | 551 context3d()->shallowFlushCHROMIUM(); |
| 549 command_buffer_proxy->SetLatencyInfo(latency_info); | 552 command_buffer_proxy->SetLatencyInfo(frame->metadata.latency_info); |
| 550 | 553 |
| 551 if (reflector_.get()) | 554 if (reflector_.get()) { |
| 552 reflector_->OnSwapBuffers(); | 555 if (frame->gl_frame_data->partial_swap_allowed) |
| 556 reflector_->OnPostSubBuffer(frame->gl_frame_data->sub_buffer_rect); |
| 557 else |
| 558 reflector_->OnSwapBuffers(); |
| 559 } |
| 553 | 560 |
| 554 OutputSurface::SwapBuffers(latency_info); | 561 OutputSurface::SwapBuffers(frame); |
| 555 } | |
| 556 | |
| 557 virtual void PostSubBuffer(gfx::Rect rect, | |
| 558 const ui::LatencyInfo& latency_info) OVERRIDE { | |
| 559 WebGraphicsContext3DCommandBufferImpl* command_buffer = | |
| 560 static_cast<WebGraphicsContext3DCommandBufferImpl*>(context3d()); | |
| 561 CommandBufferProxyImpl* command_buffer_proxy = | |
| 562 command_buffer->GetCommandBufferProxy(); | |
| 563 DCHECK(command_buffer_proxy); | |
| 564 context3d()->shallowFlushCHROMIUM(); | |
| 565 command_buffer_proxy->SetLatencyInfo(latency_info); | |
| 566 | |
| 567 if (reflector_.get()) | |
| 568 reflector_->OnPostSubBuffer(rect); | |
| 569 | |
| 570 OutputSurface::PostSubBuffer(rect, latency_info); | |
| 571 } | 562 } |
| 572 | 563 |
| 573 void SetReflector(ReflectorImpl* reflector) { | 564 void SetReflector(ReflectorImpl* reflector) { |
| 574 reflector_ = reflector; | 565 reflector_ = reflector; |
| 575 } | 566 } |
| 576 | 567 |
| 577 private: | 568 private: |
| 578 int surface_id_; | 569 int surface_id_; |
| 579 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; | 570 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; |
| 580 | 571 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 delete g_factory; | 1047 delete g_factory; |
| 1057 g_factory = NULL; | 1048 g_factory = NULL; |
| 1058 } | 1049 } |
| 1059 | 1050 |
| 1060 // static | 1051 // static |
| 1061 ImageTransportFactory* ImageTransportFactory::GetInstance() { | 1052 ImageTransportFactory* ImageTransportFactory::GetInstance() { |
| 1062 return g_factory; | 1053 return g_factory; |
| 1063 } | 1054 } |
| 1064 | 1055 |
| 1065 } // namespace content | 1056 } // namespace content |
| OLD | NEW |