// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ #define COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_ #include "base/macros.h" #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "base/threading/thread_checker.h" #include "components/mus/public/interfaces/compositor_frame.mojom.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/interface_ptr_info.h" namespace mus { class WindowSurfaceBinding; class WindowSurfaceClient; class Window; // A WindowSurface is wrapper to simplify submitting CompositorFrames to // Windows, and receiving ReturnedResources. class WindowSurface : public mojom::SurfaceClient { public: // static static scoped_ptr Create( scoped_ptr* surface_binding); ~WindowSurface() override; // Called to indicate that the current thread has assumed control of this // object. void BindToThread(); void SubmitCompositorFrame(mojom::CompositorFramePtr frame, const mojo::Closure& callback); void set_client(WindowSurfaceClient* client) { client_ = client; } private: friend class Window; WindowSurface(mojo::InterfacePtrInfo surface_info, mojo::InterfaceRequest client_request); // SurfaceClient implementation: void ReturnResources( mojo::Array resources) override; WindowSurfaceClient* client_; mojo::InterfacePtrInfo surface_info_; mojo::InterfaceRequest client_request_; mojom::SurfacePtr surface_; scoped_ptr> client_binding_; scoped_ptr thread_checker_; DISALLOW_COPY_AND_ASSIGN(WindowSurface); }; // A WindowSurfaceBinding is a bundle of mojo interfaces that are to be used by // or implemented by the Mus window server when passed into // Window::AttachSurface. WindowSurfaceBinding has no standalone functionality. class WindowSurfaceBinding { public: ~WindowSurfaceBinding(); private: friend class WindowSurface; friend class Window; WindowSurfaceBinding( mojo::InterfaceRequest surface_request, mojo::InterfacePtrInfo surface_client); mojo::InterfaceRequest surface_request_; mojo::InterfacePtrInfo surface_client_; DISALLOW_COPY_AND_ASSIGN(WindowSurfaceBinding); }; } // namespace mus #endif // COMPONENTS_MUS_PUBLIC_CPP_WINDOW_SURFACE_H_