Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/gpu_browser_compositor_output_surface.h" | 5 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "cc/output/output_surface_client.h" | 10 #include "cc/output/output_surface_client.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 } | 77 } |
| 78 | 78 |
| 79 void GpuBrowserCompositorOutputSurface::BindFramebuffer() { | 79 void GpuBrowserCompositorOutputSurface::BindFramebuffer() { |
| 80 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 80 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void GpuBrowserCompositorOutputSurface::Reshape( | 83 void GpuBrowserCompositorOutputSurface::Reshape( |
| 84 const gfx::Size& size, | 84 const gfx::Size& size, |
| 85 float device_scale_factor, | 85 float device_scale_factor, |
| 86 const gfx::ColorSpace& color_space, | 86 const gfx::ColorSpace& color_space, |
| 87 bool has_alpha) { | 87 bool has_alpha) { |
|
sunnyps
2017/01/28 01:33:58
can we add a flag to check if set draw rect after
| |
| 88 context_provider()->ContextGL()->ResizeCHROMIUM( | 88 context_provider()->ContextGL()->ResizeCHROMIUM( |
| 89 size.width(), size.height(), device_scale_factor, has_alpha); | 89 size.width(), size.height(), device_scale_factor, has_alpha); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void GpuBrowserCompositorOutputSurface::SwapBuffers( | 92 void GpuBrowserCompositorOutputSurface::SwapBuffers( |
| 93 cc::OutputSurfaceFrame frame) { | 93 cc::OutputSurfaceFrame frame) { |
| 94 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info); | 94 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info); |
| 95 | 95 |
| 96 gfx::Rect swap_rect = frame.sub_buffer_rect; | 96 gfx::Rect swap_rect = frame.sub_buffer_rect; |
| 97 gfx::Size surface_size = frame.size; | 97 gfx::Size surface_size = frame.size; |
| 98 if (reflector_) { | 98 if (reflector_) { |
| 99 if (swap_rect == gfx::Rect(surface_size)) { | 99 if (swap_rect == gfx::Rect(surface_size)) { |
| 100 reflector_texture_->CopyTextureFullImage(surface_size); | 100 reflector_texture_->CopyTextureFullImage(surface_size); |
| 101 reflector_->OnSourceSwapBuffers(surface_size); | 101 reflector_->OnSourceSwapBuffers(surface_size); |
| 102 } else { | 102 } else { |
| 103 reflector_texture_->CopyTextureSubImage(swap_rect); | 103 reflector_texture_->CopyTextureSubImage(swap_rect); |
| 104 reflector_->OnSourcePostSubBuffer(swap_rect, surface_size); | 104 reflector_->OnSourcePostSubBuffer(swap_rect, surface_size); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 set_draw_rectangle_for_frame_ = false; | |
| 109 | |
| 108 if (swap_rect == gfx::Rect(frame.size)) | 110 if (swap_rect == gfx::Rect(frame.size)) |
| 109 context_provider_->ContextSupport()->Swap(); | 111 context_provider_->ContextSupport()->Swap(); |
| 110 else | 112 else |
| 111 context_provider_->ContextSupport()->PartialSwapBuffers(swap_rect); | 113 context_provider_->ContextSupport()->PartialSwapBuffers(swap_rect); |
| 112 } | 114 } |
| 113 | 115 |
| 114 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { | 116 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { |
| 115 auto* gl = static_cast<ui::ContextProviderCommandBuffer*>(context_provider()); | 117 auto* gl = static_cast<ui::ContextProviderCommandBuffer*>(context_provider()); |
| 116 return gl->GetCopyTextureInternalFormat(); | 118 return gl->GetCopyTextureInternalFormat(); |
| 117 } | 119 } |
| 118 | 120 |
| 119 bool GpuBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() const { | 121 bool GpuBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() const { |
| 120 return false; | 122 return false; |
| 121 } | 123 } |
| 122 | 124 |
| 123 unsigned GpuBrowserCompositorOutputSurface::GetOverlayTextureId() const { | 125 unsigned GpuBrowserCompositorOutputSurface::GetOverlayTextureId() const { |
| 124 return 0; | 126 return 0; |
| 125 } | 127 } |
| 126 | 128 |
| 127 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { | 129 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { |
| 128 return false; | 130 return false; |
| 129 } | 131 } |
| 130 | 132 |
| 131 #if defined(OS_MACOSX) | 133 #if defined(OS_MACOSX) |
| 132 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( | 134 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( |
| 133 bool suspended) {} | 135 bool suspended) {} |
| 134 #endif | 136 #endif |
| 135 | 137 |
| 138 void GpuBrowserCompositorOutputSurface::SetDrawRectangle( | |
| 139 const gfx::Rect& rect) { | |
| 140 if (set_draw_rectangle_for_frame_) | |
|
sunnyps
2017/01/28 01:33:58
should we dcheck/check(!set_draw_rectangle_for_fra
sunnyps
2017/01/28 01:33:58
can we dcheck/check that rect is a subrect of surf
| |
| 141 return; | |
| 142 set_draw_rectangle_for_frame_ = true; | |
| 143 context_provider()->ContextGL()->SetDrawRectangleCHROMIUM( | |
| 144 rect.x(), rect.y(), rect.width(), rect.height()); | |
| 145 } | |
| 146 | |
| 136 gpu::CommandBufferProxyImpl* | 147 gpu::CommandBufferProxyImpl* |
| 137 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { | 148 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { |
| 138 ui::ContextProviderCommandBuffer* provider_command_buffer = | 149 ui::ContextProviderCommandBuffer* provider_command_buffer = |
| 139 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get()); | 150 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get()); |
| 140 gpu::CommandBufferProxyImpl* command_buffer_proxy = | 151 gpu::CommandBufferProxyImpl* command_buffer_proxy = |
| 141 provider_command_buffer->GetCommandBufferProxy(); | 152 provider_command_buffer->GetCommandBufferProxy(); |
| 142 DCHECK(command_buffer_proxy); | 153 DCHECK(command_buffer_proxy); |
| 143 return command_buffer_proxy; | 154 return command_buffer_proxy; |
| 144 } | 155 } |
| 145 | 156 |
| 146 } // namespace content | 157 } // namespace content |
| OLD | NEW |