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/cancelable_callback.h" |
| 12 #include "base/macros.h" |
| 13 #include "build/build_config.h" |
| 14 #include "components/mus/public/cpp/window_surface_client.h" |
| 15 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h" |
| 16 #include "gpu/command_buffer/common/mailbox.h" |
| 17 #include "gpu/ipc/common/surface_handle.h" |
| 18 #include "ui/gfx/swap_result.h" |
| 19 |
| 20 namespace mus { |
| 21 class Window; |
| 22 class WindowSurface; |
| 23 } |
| 24 |
| 25 namespace content { |
| 26 |
| 27 // Adapts a WebGraphicsContext3DCommandBufferImpl into a |
| 28 // cc::OutputSurface that also handles vsync parameter updates |
| 29 // arriving from the GPU process. |
| 30 class MusBrowserCompositorOutputSurface |
| 31 : public GpuBrowserCompositorOutputSurface, |
| 32 public mus::WindowSurfaceClient { |
| 33 public: |
| 34 MusBrowserCompositorOutputSurface( |
| 35 gpu::SurfaceHandle surface_handle, |
| 36 scoped_refptr<ContextProviderCommandBuffer> context, |
| 37 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, |
| 38 cc::SyntheticBeginFrameSource* begin_frame_source, |
| 39 std::unique_ptr<display_compositor::CompositorOverlayCandidateValidator> |
| 40 overlay_candidate_validator); |
| 41 |
| 42 ~MusBrowserCompositorOutputSurface() override; |
| 43 |
| 44 protected: |
| 45 // cc::OutputSurface implementation. |
| 46 void SwapBuffers(cc::CompositorFrame frame) override; |
| 47 bool BindToClient(cc::OutputSurfaceClient* client) override; |
| 48 |
| 49 // mus::WindowSurfaceClient: |
| 50 void OnResourcesReturned( |
| 51 mus::WindowSurface* surface, |
| 52 mojo::Array<cc::ReturnedResource> resources) override; |
| 53 |
| 54 private: |
| 55 uint32_t AllocateResourceId(); |
| 56 void FreeResourceId(uint32_t id); |
| 57 const gpu::Mailbox& GetMailboxFromResourceId(uint32_t id); |
| 58 |
| 59 mus::Window* mus_window_; |
| 60 std::unique_ptr<mus::WindowSurface> mus_window_surface_; |
| 61 std::vector<uint32_t> free_resource_ids_; |
| 62 std::vector<gpu::Mailbox> mailboxs_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(MusBrowserCompositorOutputSurface); |
| 65 }; |
| 66 |
| 67 } // namespace content |
| 68 |
| 69 #endif // CONTENT_BROWSER_COMPOSITOR_MUS_BROWSER_COMPOSITOR_OUTPUT_SURFACE_H_ |
OLD | NEW |