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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void GpuBrowserCompositorOutputSurface::BindFramebuffer() { | 81 void GpuBrowserCompositorOutputSurface::BindFramebuffer() { |
82 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 82 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
83 } | 83 } |
84 | 84 |
85 void GpuBrowserCompositorOutputSurface::Reshape( | 85 void GpuBrowserCompositorOutputSurface::Reshape( |
86 const gfx::Size& size, | 86 const gfx::Size& size, |
87 float device_scale_factor, | 87 float device_scale_factor, |
88 const gfx::ColorSpace& color_space, | 88 const gfx::ColorSpace& color_space, |
89 bool has_alpha, | 89 bool has_alpha, |
90 bool use_stencil) { | 90 bool use_stencil) { |
| 91 size_ = size; |
| 92 has_set_draw_rectangle_ = false; |
91 context_provider()->ContextGL()->ResizeCHROMIUM( | 93 context_provider()->ContextGL()->ResizeCHROMIUM( |
92 size.width(), size.height(), device_scale_factor, has_alpha); | 94 size.width(), size.height(), device_scale_factor, has_alpha); |
93 } | 95 } |
94 | 96 |
95 void GpuBrowserCompositorOutputSurface::SwapBuffers( | 97 void GpuBrowserCompositorOutputSurface::SwapBuffers( |
96 cc::OutputSurfaceFrame frame) { | 98 cc::OutputSurfaceFrame frame) { |
97 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info); | 99 GetCommandBufferProxy()->SetLatencyInfo(frame.latency_info); |
98 | 100 |
99 gfx::Rect swap_rect = frame.sub_buffer_rect; | 101 gfx::Rect swap_rect = frame.sub_buffer_rect; |
100 gfx::Size surface_size = frame.size; | 102 gfx::Size surface_size = frame.size; |
101 if (reflector_) { | 103 if (reflector_) { |
102 if (swap_rect == gfx::Rect(surface_size)) { | 104 if (swap_rect == gfx::Rect(surface_size)) { |
103 reflector_texture_->CopyTextureFullImage(surface_size); | 105 reflector_texture_->CopyTextureFullImage(surface_size); |
104 reflector_->OnSourceSwapBuffers(surface_size); | 106 reflector_->OnSourceSwapBuffers(surface_size); |
105 } else { | 107 } else { |
106 reflector_texture_->CopyTextureSubImage(swap_rect); | 108 reflector_texture_->CopyTextureSubImage(swap_rect); |
107 reflector_->OnSourcePostSubBuffer(swap_rect, surface_size); | 109 reflector_->OnSourcePostSubBuffer(swap_rect, surface_size); |
108 } | 110 } |
109 } | 111 } |
110 | 112 |
| 113 set_draw_rectangle_for_frame_ = false; |
| 114 |
111 if (swap_rect == gfx::Rect(frame.size)) | 115 if (swap_rect == gfx::Rect(frame.size)) |
112 context_provider_->ContextSupport()->Swap(); | 116 context_provider_->ContextSupport()->Swap(); |
113 else | 117 else |
114 context_provider_->ContextSupport()->PartialSwapBuffers(swap_rect); | 118 context_provider_->ContextSupport()->PartialSwapBuffers(swap_rect); |
115 } | 119 } |
116 | 120 |
117 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { | 121 uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { |
118 auto* gl = static_cast<ui::ContextProviderCommandBuffer*>(context_provider()); | 122 auto* gl = static_cast<ui::ContextProviderCommandBuffer*>(context_provider()); |
119 return gl->GetCopyTextureInternalFormat(); | 123 return gl->GetCopyTextureInternalFormat(); |
120 } | 124 } |
121 | 125 |
122 bool GpuBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() const { | 126 bool GpuBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() const { |
123 return false; | 127 return false; |
124 } | 128 } |
125 | 129 |
126 unsigned GpuBrowserCompositorOutputSurface::GetOverlayTextureId() const { | 130 unsigned GpuBrowserCompositorOutputSurface::GetOverlayTextureId() const { |
127 return 0; | 131 return 0; |
128 } | 132 } |
129 | 133 |
130 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { | 134 bool GpuBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() const { |
131 return false; | 135 return false; |
132 } | 136 } |
133 | 137 |
134 #if defined(OS_MACOSX) | 138 #if defined(OS_MACOSX) |
135 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( | 139 void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle( |
136 bool suspended) {} | 140 bool suspended) {} |
137 #endif | 141 #endif |
138 | 142 |
| 143 void GpuBrowserCompositorOutputSurface::SetDrawRectangle( |
| 144 const gfx::Rect& rect) { |
| 145 if (set_draw_rectangle_for_frame_) |
| 146 return; |
| 147 DCHECK(gfx::Rect(size_).Contains(rect)); |
| 148 DCHECK(has_set_draw_rectangle_ || (gfx::Rect(size_) == rect)); |
| 149 set_draw_rectangle_for_frame_ = true; |
| 150 has_set_draw_rectangle_ = true; |
| 151 context_provider()->ContextGL()->SetDrawRectangleCHROMIUM( |
| 152 rect.x(), rect.y(), rect.width(), rect.height()); |
| 153 } |
| 154 |
139 gpu::CommandBufferProxyImpl* | 155 gpu::CommandBufferProxyImpl* |
140 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { | 156 GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() { |
141 ui::ContextProviderCommandBuffer* provider_command_buffer = | 157 ui::ContextProviderCommandBuffer* provider_command_buffer = |
142 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get()); | 158 static_cast<ui::ContextProviderCommandBuffer*>(context_provider_.get()); |
143 gpu::CommandBufferProxyImpl* command_buffer_proxy = | 159 gpu::CommandBufferProxyImpl* command_buffer_proxy = |
144 provider_command_buffer->GetCommandBufferProxy(); | 160 provider_command_buffer->GetCommandBufferProxy(); |
145 DCHECK(command_buffer_proxy); | 161 DCHECK(command_buffer_proxy); |
146 return command_buffer_proxy; | 162 return command_buffer_proxy; |
147 } | 163 } |
148 | 164 |
149 } // namespace content | 165 } // namespace content |
OLD | NEW |