OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_COMPOSITOR_MUS_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ |
| 6 #define CONTENT_BROWSER_COMPOSITOR_MUS_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
| 13 #include "gpu/command_buffer/common/mailbox.h" |
| 14 #include "gpu/ipc/common/surface_handle.h" |
| 15 #include "services/ui/public/cpp/window_surface_client.h" |
| 16 |
| 17 namespace ui { |
| 18 class Window; |
| 19 class WindowSurface; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 // Adapts a WebGraphicsContext3DCommandBufferImpl into a |
| 25 // cc::OutputSurface that also handles vsync parameter updates |
| 26 // arriving from the GPU process. |
| 27 class MusBrowserCompositorOutputSurface |
| 28 : public GpuBrowserCompositorOutputSurface, |
| 29 public ui::WindowSurfaceClient { |
| 30 public: |
| 31 MusBrowserCompositorOutputSurface( |
| 32 gpu::SurfaceHandle surface_handle, |
| 33 scoped_refptr<ContextProviderCommandBuffer> context, |
| 34 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, |
| 35 cc::SyntheticBeginFrameSource* begin_frame_source, |
| 36 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 37 overlay_candidate_validator); |
| 38 |
| 39 ~MusBrowserCompositorOutputSurface() override; |
| 40 |
| 41 protected: |
| 42 // cc::OutputSurface implementation. |
| 43 void SwapBuffers(cc::CompositorFrame frame) override; |
| 44 bool BindToClient(cc::OutputSurfaceClient* client) override; |
| 45 |
| 46 // ui::WindowSurfaceClient: |
| 47 void OnResourcesReturned( |
| 48 ui::WindowSurface* surface, |
| 49 mojo::Array<cc::ReturnedResource> resources) override; |
| 50 |
| 51 private: |
| 52 uint32_t AllocateResourceId(); |
| 53 void FreeResourceId(uint32_t id); |
| 54 const gpu::Mailbox& GetMailboxFromResourceId(uint32_t id); |
| 55 |
| 56 ui::Window* ui_window_; |
| 57 std::unique_ptr<ui::WindowSurface> ui_window_surface_; |
| 58 std::vector<uint32_t> free_resource_ids_; |
| 59 std::vector<gpu::Mailbox> mailboxes_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(MusBrowserCompositorOutputSurface); |
| 62 }; |
| 63 |
| 64 } // namespace content |
| 65 |
| 66 #endif // CONTENT_BROWSER_COMPOSITOR_MUS_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ |
OLD | NEW |