| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 void OnMirroringCompositorResized() override {} | 43 void OnMirroringCompositorResized() override {} |
| 44 void AddMirroringLayer(Layer* layer) override {} | 44 void AddMirroringLayer(Layer* layer) override {} |
| 45 void RemoveMirroringLayer(Layer* layer) override {} | 45 void RemoveMirroringLayer(Layer* layer) override {} |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 // An OutputSurface implementation that directly draws and swaps to an actual | 48 // An OutputSurface implementation that directly draws and swaps to an actual |
| 49 // GL surface. | 49 // GL surface. |
| 50 class DirectOutputSurface : public cc::OutputSurface { | 50 class DirectOutputSurface : public cc::OutputSurface { |
| 51 public: | 51 public: |
| 52 DirectOutputSurface( | 52 DirectOutputSurface( |
| 53 scoped_refptr<cc::ContextProvider> context_provider, | 53 scoped_refptr<InProcessContextProvider> context_provider, |
| 54 scoped_refptr<cc::ContextProvider> worker_context_provider) | 54 scoped_refptr<InProcessContextProvider> worker_context_provider) |
| 55 : cc::OutputSurface(std::move(context_provider), | 55 : cc::OutputSurface(std::move(context_provider), |
| 56 std::move(worker_context_provider), | 56 std::move(worker_context_provider), |
| 57 nullptr), | 57 nullptr), |
| 58 weak_ptr_factory_(this) {} | 58 weak_ptr_factory_(this) {} |
| 59 | 59 |
| 60 ~DirectOutputSurface() override {} | 60 ~DirectOutputSurface() override {} |
| 61 | 61 |
| 62 // cc::OutputSurface implementation | 62 // cc::OutputSurface implementation. |
| 63 bool BindToClient(cc::OutputSurfaceClient* client) override { | 63 bool BindToClient(cc::OutputSurfaceClient* client) override { |
| 64 if (!OutputSurface::BindToClient(client)) | 64 if (!OutputSurface::BindToClient(client)) |
| 65 return false; | 65 return false; |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 void SwapBuffers(cc::CompositorFrame* frame) override { | 68 void SwapBuffers(cc::CompositorFrame* frame) override { |
| 69 DCHECK(context_provider_.get()); | 69 DCHECK(context_provider_.get()); |
| 70 DCHECK(frame->gl_frame_data); | 70 DCHECK(frame->gl_frame_data); |
| 71 if (frame->gl_frame_data->sub_buffer_rect == | 71 if (frame->gl_frame_data->sub_buffer_rect == |
| 72 gfx::Rect(frame->gl_frame_data->size)) { | 72 gfx::Rect(frame->gl_frame_data->size)) { |
| 73 context_provider_->ContextSupport()->Swap(); | 73 context_provider_->ContextSupport()->Swap(); |
| 74 } else { | 74 } else { |
| 75 context_provider_->ContextSupport()->PartialSwapBuffers( | 75 context_provider_->ContextSupport()->PartialSwapBuffers( |
| 76 frame->gl_frame_data->sub_buffer_rect); | 76 frame->gl_frame_data->sub_buffer_rect); |
| 77 } | 77 } |
| 78 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 78 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 79 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 79 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 80 gl->ShallowFlushCHROMIUM(); | 80 gl->ShallowFlushCHROMIUM(); |
| 81 | 81 |
| 82 gpu::SyncToken sync_token; | 82 gpu::SyncToken sync_token; |
| 83 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 83 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 84 | 84 |
| 85 context_provider_->ContextSupport()->SignalSyncToken( | 85 context_provider_->ContextSupport()->SignalSyncToken( |
| 86 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, | 86 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, |
| 87 weak_ptr_factory_.GetWeakPtr())); | 87 weak_ptr_factory_.GetWeakPtr())); |
| 88 client_->DidSwapBuffers(); | 88 client_->DidSwapBuffers(); |
| 89 } | 89 } |
| 90 uint32_t GetFramebufferCopyTextureFormat() override { |
| 91 auto* gl = static_cast<InProcessContextProvider*>(context_provider()); |
| 92 return gl->GetCopyTextureInternalFormat(); |
| 93 } |
| 90 | 94 |
| 91 private: | 95 private: |
| 92 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; | 96 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; |
| 93 | 97 |
| 94 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); | 98 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); |
| 95 }; | 99 }; |
| 96 | 100 |
| 97 } // namespace | 101 } // namespace |
| 98 | 102 |
| 99 InProcessContextFactory::InProcessContextFactory( | 103 InProcessContextFactory::InProcessContextFactory( |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } | 259 } |
| 256 | 260 |
| 257 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 261 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
| 258 const gfx::Size& size) { | 262 const gfx::Size& size) { |
| 259 if (!per_compositor_data_.count(compositor)) | 263 if (!per_compositor_data_.count(compositor)) |
| 260 return; | 264 return; |
| 261 per_compositor_data_[compositor]->Resize(size); | 265 per_compositor_data_[compositor]->Resize(size); |
| 262 } | 266 } |
| 263 | 267 |
| 264 } // namespace ui | 268 } // namespace ui |
| OLD | NEW |