| 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 "ui/compositor/test/in_process_context_factory.h" | 5 #include "ui/compositor/test/in_process_context_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // GL surface. | 49 // GL surface. |
| 50 class DirectOutputSurface : public cc::OutputSurface { | 50 class DirectOutputSurface : public cc::OutputSurface { |
| 51 public: | 51 public: |
| 52 DirectOutputSurface(scoped_refptr<InProcessContextProvider> context_provider) | 52 DirectOutputSurface(scoped_refptr<InProcessContextProvider> context_provider) |
| 53 : cc::OutputSurface(std::move(context_provider)), | 53 : cc::OutputSurface(std::move(context_provider)), |
| 54 weak_ptr_factory_(this) {} | 54 weak_ptr_factory_(this) {} |
| 55 | 55 |
| 56 ~DirectOutputSurface() override {} | 56 ~DirectOutputSurface() override {} |
| 57 | 57 |
| 58 // cc::OutputSurface implementation. | 58 // cc::OutputSurface implementation. |
| 59 void EnsureBackbuffer() override {} |
| 60 void DiscardBackbuffer() override {} |
| 61 void BindFramebuffer() override { |
| 62 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
| 63 } |
| 59 bool BindToClient(cc::OutputSurfaceClient* client) override { | 64 bool BindToClient(cc::OutputSurfaceClient* client) override { |
| 60 if (!OutputSurface::BindToClient(client)) | 65 if (!OutputSurface::BindToClient(client)) |
| 61 return false; | 66 return false; |
| 62 return true; | 67 return true; |
| 63 } | 68 } |
| 64 void SwapBuffers(cc::CompositorFrame frame) override { | 69 void SwapBuffers(cc::CompositorFrame frame) override { |
| 65 DCHECK(context_provider_.get()); | 70 DCHECK(context_provider_.get()); |
| 66 DCHECK(frame.gl_frame_data); | 71 DCHECK(frame.gl_frame_data); |
| 67 if (frame.gl_frame_data->sub_buffer_rect == | 72 if (frame.gl_frame_data->sub_buffer_rect == |
| 68 gfx::Rect(frame.gl_frame_data->size)) { | 73 gfx::Rect(frame.gl_frame_data->size)) { |
| 69 context_provider_->ContextSupport()->Swap(); | 74 context_provider_->ContextSupport()->Swap(); |
| 70 } else { | 75 } else { |
| 71 context_provider_->ContextSupport()->PartialSwapBuffers( | 76 context_provider_->ContextSupport()->PartialSwapBuffers( |
| 72 frame.gl_frame_data->sub_buffer_rect); | 77 frame.gl_frame_data->sub_buffer_rect); |
| 73 } | 78 } |
| 74 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 79 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 75 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 80 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 76 gl->ShallowFlushCHROMIUM(); | 81 gl->ShallowFlushCHROMIUM(); |
| 77 | 82 |
| 78 gpu::SyncToken sync_token; | 83 gpu::SyncToken sync_token; |
| 79 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 84 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 80 | 85 |
| 81 context_provider_->ContextSupport()->SignalSyncToken( | 86 context_provider_->ContextSupport()->SignalSyncToken( |
| 82 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, | 87 sync_token, base::Bind(&DirectOutputSurface::OnSwapBuffersComplete, |
| 83 weak_ptr_factory_.GetWeakPtr())); | 88 weak_ptr_factory_.GetWeakPtr())); |
| 84 } | 89 } |
| 85 uint32_t GetFramebufferCopyTextureFormat() override { | 90 uint32_t GetFramebufferCopyTextureFormat() override { |
| 86 auto* gl = static_cast<InProcessContextProvider*>(context_provider()); | 91 auto* gl = static_cast<InProcessContextProvider*>(context_provider()); |
| 87 return gl->GetCopyTextureInternalFormat(); | 92 return gl->GetCopyTextureInternalFormat(); |
| 88 } | 93 } |
| 94 cc::OverlayCandidateValidator* GetOverlayCandidateValidator() const override { |
| 95 return nullptr; |
| 96 } |
| 97 bool IsDisplayedAsOverlayPlane() const override { return false; } |
| 98 unsigned GetOverlayTextureId() const override { return 0; } |
| 99 bool SurfaceIsSuspendForRecycle() const override { return false; } |
| 100 bool HasExternalStencilTest() const override { return false; } |
| 101 void ApplyExternalStencil() override {} |
| 89 | 102 |
| 90 private: | 103 private: |
| 104 void OnSwapBuffersComplete() { client_->DidSwapBuffersComplete(); } |
| 105 |
| 91 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; | 106 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; |
| 92 | 107 |
| 93 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); | 108 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); |
| 94 }; | 109 }; |
| 95 | 110 |
| 96 } // namespace | 111 } // namespace |
| 97 | 112 |
| 98 InProcessContextFactory::InProcessContextFactory( | 113 InProcessContextFactory::InProcessContextFactory( |
| 99 bool context_factory_for_test, | 114 bool context_factory_for_test, |
| 100 cc::SurfaceManager* surface_manager) | 115 cc::SurfaceManager* surface_manager) |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 277 |
| 263 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { | 278 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { |
| 264 observer_list_.AddObserver(observer); | 279 observer_list_.AddObserver(observer); |
| 265 } | 280 } |
| 266 | 281 |
| 267 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { | 282 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { |
| 268 observer_list_.RemoveObserver(observer); | 283 observer_list_.RemoveObserver(observer); |
| 269 } | 284 } |
| 270 | 285 |
| 271 } // namespace ui | 286 } // namespace ui |
| OLD | NEW |