| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/offscreen_browser_compositor_output_surface
.h" | 5 #include "content/browser/compositor/offscreen_browser_compositor_output_surface
.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "cc/output/compositor_frame.h" | |
| 12 #include "cc/output/gl_frame_data.h" | |
| 13 #include "cc/output/output_surface_client.h" | 11 #include "cc/output/output_surface_client.h" |
| 12 #include "cc/output/output_surface_frame.h" |
| 14 #include "cc/resources/resource_provider.h" | 13 #include "cc/resources/resource_provider.h" |
| 15 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" | 14 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" |
| 16 #include "content/browser/compositor/reflector_impl.h" | 15 #include "content/browser/compositor/reflector_impl.h" |
| 17 #include "content/browser/compositor/reflector_texture.h" | 16 #include "content/browser/compositor/reflector_texture.h" |
| 18 #include "content/common/gpu/client/context_provider_command_buffer.h" | 17 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 #include "gpu/command_buffer/client/context_support.h" | 19 #include "gpu/command_buffer/client/context_support.h" |
| 21 #include "gpu/command_buffer/client/gles2_interface.h" | 20 #include "gpu/command_buffer/client/gles2_interface.h" |
| 22 #include "third_party/khronos/GLES2/gl2.h" | 21 #include "third_party/khronos/GLES2/gl2.h" |
| 23 #include "third_party/khronos/GLES2/gl2ext.h" | 22 #include "third_party/khronos/GLES2/gl2ext.h" |
| 24 | 23 |
| 25 using cc::CompositorFrame; | |
| 26 using cc::GLFrameData; | |
| 27 using cc::ResourceProvider; | |
| 28 using gpu::gles2::GLES2Interface; | 24 using gpu::gles2::GLES2Interface; |
| 29 | 25 |
| 30 namespace content { | 26 namespace content { |
| 31 | 27 |
| 32 static cc::ResourceFormat kFboTextureFormat = cc::RGBA_8888; | 28 static cc::ResourceFormat kFboTextureFormat = cc::RGBA_8888; |
| 33 | 29 |
| 34 OffscreenBrowserCompositorOutputSurface:: | 30 OffscreenBrowserCompositorOutputSurface:: |
| 35 OffscreenBrowserCompositorOutputSurface( | 31 OffscreenBrowserCompositorOutputSurface( |
| 36 scoped_refptr<ContextProviderCommandBuffer> context, | 32 scoped_refptr<ContextProviderCommandBuffer> context, |
| 37 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, | 33 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 DCHECK(reflector_texture_.get()); | 123 DCHECK(reflector_texture_.get()); |
| 128 DCHECK(fbo_); | 124 DCHECK(fbo_); |
| 129 | 125 |
| 130 if (need_to_bind) { | 126 if (need_to_bind) { |
| 131 GLES2Interface* gl = context_provider_->ContextGL(); | 127 GLES2Interface* gl = context_provider_->ContextGL(); |
| 132 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); | 128 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| 133 } | 129 } |
| 134 } | 130 } |
| 135 | 131 |
| 136 void OffscreenBrowserCompositorOutputSurface::SwapBuffers( | 132 void OffscreenBrowserCompositorOutputSurface::SwapBuffers( |
| 137 cc::CompositorFrame frame) { | 133 cc::OutputSurfaceFrame frame) { |
| 138 if (reflector_) { | 134 if (reflector_) { |
| 139 if (frame.gl_frame_data->sub_buffer_rect == | 135 if (frame.sub_buffer_rect == gfx::Rect(frame.size)) |
| 140 gfx::Rect(frame.gl_frame_data->size)) | |
| 141 reflector_->OnSourceSwapBuffers(); | 136 reflector_->OnSourceSwapBuffers(); |
| 142 else | 137 else |
| 143 reflector_->OnSourcePostSubBuffer(frame.gl_frame_data->sub_buffer_rect); | 138 reflector_->OnSourcePostSubBuffer(frame.sub_buffer_rect); |
| 144 } | 139 } |
| 145 | 140 |
| 146 // TODO(oshima): sync with the reflector's SwapBuffersComplete | 141 // TODO(oshima): sync with the reflector's SwapBuffersComplete |
| 147 // (crbug.com/520567). | 142 // (crbug.com/520567). |
| 148 // The original implementation had a flickering issue (crbug.com/515332). | 143 // The original implementation had a flickering issue (crbug.com/515332). |
| 149 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 144 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 150 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 145 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 151 gl->ShallowFlushCHROMIUM(); | 146 gl->ShallowFlushCHROMIUM(); |
| 152 | 147 |
| 153 gpu::SyncToken sync_token; | 148 gpu::SyncToken sync_token; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 183 reflector_changed_ = true; | 178 reflector_changed_ = true; |
| 184 EnsureBackbuffer(); | 179 EnsureBackbuffer(); |
| 185 } | 180 } |
| 186 } | 181 } |
| 187 | 182 |
| 188 void OffscreenBrowserCompositorOutputSurface::OnSwapBuffersComplete() { | 183 void OffscreenBrowserCompositorOutputSurface::OnSwapBuffersComplete() { |
| 189 client_->DidSwapBuffersComplete(); | 184 client_->DidSwapBuffersComplete(); |
| 190 } | 185 } |
| 191 | 186 |
| 192 } // namespace content | 187 } // namespace content |
| OLD | NEW |