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 3 // found in the LICENSE file. 4 5 #ifndef MOJO_SERVICES_SURFACES_SURFACES_IMPL_H_ 6 #define MOJO_SERVICES_SURFACES_SURFACES_IMPL_H_ 7 8 #include "base/compiler_specific.h" 9 #include "cc/surfaces/display_client.h" 10 #include "cc/surfaces/surface_factory.h" 11 #include "cc/surfaces/surface_factory_client.h" 12 #include "mojo/public/cpp/application/application_connection.h" 13 #include "mojo/services/gles2/command_buffer.mojom.h" 14 #include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h" 15 16 namespace cc { 17 class Display; 18 } 19 20 namespace mojo { 21 class ApplicationManager; 22 23 class SurfaceNativeViewportClient; 24 25 class SurfacesImpl : public InterfaceImpl<Surface>, 26 public cc::SurfaceFactoryClient, 27 public cc::DisplayClient { 28 public: 29 class Client { 30 public: 31 virtual void FrameSubmitted() = 0; 32 virtual void SetDisplay(cc::Display*) = 0; 33 }; 34 35 SurfacesImpl(cc::SurfaceManager* manager, 36 uint32_t id_namespace, 37 Client* client); 38 virtual ~SurfacesImpl(); 39 40 // Surface implementation. 41 virtual void CreateSurface(SurfaceIdPtr id, mojo::SizePtr size) OVERRIDE; 42 virtual void SubmitFrame(SurfaceIdPtr id, FramePtr frame) OVERRIDE; 43 virtual void DestroySurface(SurfaceIdPtr id) OVERRIDE; 44 virtual void CreateGLES2BoundSurface(CommandBufferPtr gles2_client, 45 SurfaceIdPtr id, 46 mojo::SizePtr size) OVERRIDE; 47 48 // SurfaceFactoryClient implementation. 49 virtual void ReturnResources( 50 const cc::ReturnedResourceArray& resources) OVERRIDE; 51 52 // DisplayClient implementation. 53 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface() OVERRIDE; 54 virtual void DisplayDamaged() OVERRIDE; 55 virtual void DidSwapBuffers() OVERRIDE; 56 virtual void DidSwapBuffersComplete() OVERRIDE; 57 virtual void CommitVSyncParameters(base::TimeTicks timebase, 58 base::TimeDelta interval) OVERRIDE; 59 factory()60 cc::SurfaceFactory* factory() { return &factory_; } 61 62 private: 63 cc::SurfaceManager* manager_; 64 cc::SurfaceFactory factory_; 65 uint32_t id_namespace_; 66 Client* client_; 67 scoped_ptr<cc::Display> display_; 68 ScopedMessagePipeHandle command_buffer_handle_; 69 70 DISALLOW_COPY_AND_ASSIGN(SurfacesImpl); 71 }; 72 73 } // namespace mojo 74 75 #endif // MOJO_SERVICES_SURFACES_SURFACES_IMPL_H_ 76