| 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" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 bool need_to_bind = !!reflector_texture_.get(); | 123 bool need_to_bind = !!reflector_texture_.get(); |
| 124 EnsureBackbuffer(); | 124 EnsureBackbuffer(); |
| 125 DCHECK(reflector_texture_.get()); | 125 DCHECK(reflector_texture_.get()); |
| 126 | 126 |
| 127 if (need_to_bind) { | 127 if (need_to_bind) { |
| 128 GLES2Interface* gl = context_provider_->ContextGL(); | 128 GLES2Interface* gl = context_provider_->ContextGL(); |
| 129 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); | 129 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 GLenum | |
| 134 OffscreenBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { | |
| 135 return GLCopyTextureInternalFormat(kFboTextureFormat); | |
| 136 } | |
| 137 | |
| 138 void OffscreenBrowserCompositorOutputSurface::SwapBuffers( | 133 void OffscreenBrowserCompositorOutputSurface::SwapBuffers( |
| 139 cc::CompositorFrame frame) { | 134 cc::CompositorFrame frame) { |
| 140 if (reflector_) { | 135 if (reflector_) { |
| 141 if (frame.gl_frame_data->sub_buffer_rect == | 136 if (frame.gl_frame_data->sub_buffer_rect == |
| 142 gfx::Rect(frame.gl_frame_data->size)) | 137 gfx::Rect(frame.gl_frame_data->size)) |
| 143 reflector_->OnSourceSwapBuffers(); | 138 reflector_->OnSourceSwapBuffers(); |
| 144 else | 139 else |
| 145 reflector_->OnSourcePostSubBuffer(frame.gl_frame_data->sub_buffer_rect); | 140 reflector_->OnSourcePostSubBuffer(frame.gl_frame_data->sub_buffer_rect); |
| 146 } | 141 } |
| 147 | 142 |
| 148 // TODO(oshima): sync with the reflector's SwapBuffersComplete | 143 // TODO(oshima): sync with the reflector's SwapBuffersComplete |
| 149 // (crbug.com/520567). | 144 // (crbug.com/520567). |
| 150 // The original implementation had a flickering issue (crbug.com/515332). | 145 // The original implementation had a flickering issue (crbug.com/515332). |
| 151 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 146 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 152 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 147 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 153 gl->ShallowFlushCHROMIUM(); | 148 gl->ShallowFlushCHROMIUM(); |
| 154 | 149 |
| 155 gpu::SyncToken sync_token; | 150 gpu::SyncToken sync_token; |
| 156 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 151 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 157 context_provider_->ContextSupport()->SignalSyncToken( | 152 context_provider_->ContextSupport()->SignalSyncToken( |
| 158 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, | 153 sync_token, |
| 159 weak_ptr_factory_.GetWeakPtr())); | 154 base::Bind( |
| 155 &OffscreenBrowserCompositorOutputSurface::OnSwapBuffersComplete, |
| 156 weak_ptr_factory_.GetWeakPtr())); |
| 157 } |
| 158 |
| 159 bool OffscreenBrowserCompositorOutputSurface::IsDisplayedAsOverlayPlane() |
| 160 const { |
| 161 return false; |
| 162 } |
| 163 |
| 164 unsigned OffscreenBrowserCompositorOutputSurface::GetOverlayTextureId() const { |
| 165 return 0; |
| 166 } |
| 167 |
| 168 bool OffscreenBrowserCompositorOutputSurface::SurfaceIsSuspendForRecycle() |
| 169 const { |
| 170 return false; |
| 171 } |
| 172 |
| 173 GLenum |
| 174 OffscreenBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() { |
| 175 return GLCopyTextureInternalFormat(kFboTextureFormat); |
| 160 } | 176 } |
| 161 | 177 |
| 162 void OffscreenBrowserCompositorOutputSurface::OnReflectorChanged() { | 178 void OffscreenBrowserCompositorOutputSurface::OnReflectorChanged() { |
| 163 if (reflector_) | 179 if (reflector_) |
| 164 EnsureBackbuffer(); | 180 EnsureBackbuffer(); |
| 165 } | 181 } |
| 166 | 182 |
| 183 void OffscreenBrowserCompositorOutputSurface::OnSwapBuffersComplete() { |
| 184 client_->DidSwapBuffersComplete(); |
| 185 } |
| 186 |
| 167 } // namespace content | 187 } // namespace content |
| OLD | NEW |