OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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 UI_AURA_LOCAL_COMPOSITOR_FRAME_SINK_LOCAL_H_ |
| 6 #define UI_AURA_LOCAL_COMPOSITOR_FRAME_SINK_LOCAL_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
| 10 #include "cc/output/compositor_frame_sink.h" |
| 11 #include "cc/scheduler/begin_frame_source.h" |
| 12 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
| 13 #include "cc/surfaces/frame_sink_id.h" |
| 14 #include "cc/surfaces/local_surface_id_allocator.h" |
| 15 #include "ui/aura/window_port.h" |
| 16 #include "ui/base/property_data.h" |
| 17 |
| 18 namespace cc { |
| 19 class CompositorFrameSinkSupport; |
| 20 class SurfaceManager; |
| 21 } |
| 22 |
| 23 namespace aura { |
| 24 |
| 25 // cc::CompositorFrameSink implementation for classic aura, e.g. not mus. |
| 26 // aura::Window::CreateCompositorFramSink creates this class for a given |
| 27 // aura::Window, and then the sink can be used for submitting frames to the |
| 28 // aura::Window's ui::Layer. |
| 29 class CompositorFrameSinkLocal : public cc::CompositorFrameSink, |
| 30 public cc::CompositorFrameSinkSupportClient, |
| 31 public cc::ExternalBeginFrameSourceClient { |
| 32 public: |
| 33 CompositorFrameSinkLocal(const cc::FrameSinkId& frame_sink_id, |
| 34 cc::SurfaceManager* surface_manager); |
| 35 ~CompositorFrameSinkLocal() override; |
| 36 |
| 37 using SurfaceChangedCallback = |
| 38 base::Callback<void(const cc::SurfaceId&, const gfx::Size&)>; |
| 39 // Set a callback which will be called when the surface is changed. |
| 40 void SetSurfaceChangedCallback(const SurfaceChangedCallback& callback); |
| 41 |
| 42 // cc::CompositorFrameSink: |
| 43 bool BindToClient(cc::CompositorFrameSinkClient* client) override; |
| 44 void DetachFromClient() override; |
| 45 void SubmitCompositorFrame(cc::CompositorFrame frame) override; |
| 46 |
| 47 // cc::CompositorFrameSinkSupportClient: |
| 48 void DidReceiveCompositorFrameAck( |
| 49 const cc::ReturnedResourceArray& resources) override; |
| 50 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 51 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
| 52 void WillDrawSurface(const cc::LocalSurfaceId& local_surface_id, |
| 53 const gfx::Rect& damage_rect) override {} |
| 54 |
| 55 // cc::ExternalBeginFrameSourceClient: |
| 56 void OnNeedsBeginFrames(bool needs_begin_frames) override; |
| 57 void OnDidFinishFrame(const cc::BeginFrameAck& ack) override; |
| 58 |
| 59 private: |
| 60 const cc::FrameSinkId frame_sink_id_; |
| 61 cc::SurfaceManager* const surface_manager_; |
| 62 std::unique_ptr<cc::CompositorFrameSinkSupport> support_; |
| 63 gfx::Size last_submitted_frame_size_; |
| 64 cc::LocalSurfaceIdAllocator id_allocator_; |
| 65 cc::LocalSurfaceId local_surface_id_; |
| 66 std::unique_ptr<cc::ExternalBeginFrameSource> begin_frame_source_; |
| 67 std::unique_ptr<base::ThreadChecker> thread_checker_; |
| 68 SurfaceChangedCallback surface_changed_callback_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkLocal); |
| 71 }; |
| 72 |
| 73 } // namespace aura |
| 74 |
| 75 #endif // UI_AURA_LOCAL_COMPOSITOR_FRAME_SINK_LOCAL_H_ |
OLD | NEW |