Chromium Code Reviews| 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 ANDROID_WEBVIEW_BROWSER_SURFACES_INSTANCE_H_ | |
| 6 #define ANDROID_WEBVIEW_BROWSER_SURFACES_INSTANCE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "cc/surfaces/display_client.h" | |
| 13 #include "cc/surfaces/surface_factory_client.h" | |
| 14 #include "cc/surfaces/surface_id.h" | |
| 15 | |
| 16 namespace cc { | |
| 17 class Display; | |
| 18 class SurfaceIdAllocator; | |
| 19 class SurfaceFactory; | |
| 20 class SurfaceManager; | |
| 21 } | |
| 22 | |
| 23 namespace gfx { | |
| 24 class Rect; | |
| 25 class Size; | |
| 26 class Transform; | |
| 27 } | |
| 28 | |
| 29 namespace android_webview { | |
| 30 | |
| 31 class AwGLSurface; | |
| 32 class ParentOutputSurface; | |
| 33 class ScopedAppGLStateRestore; | |
| 34 | |
| 35 class SurfacesInstance : public base::RefCounted<SurfacesInstance>, | |
| 36 public cc::DisplayClient, | |
| 37 public cc::SurfaceFactoryClient { | |
| 38 public: | |
| 39 static scoped_refptr<SurfacesInstance> GetOrCreateInstance(); | |
| 40 | |
| 41 std::unique_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator(); | |
| 42 cc::SurfaceManager* GetSurfaceManager(); | |
| 43 void SetBackingFrameBufferObject(int framebuffer_binding_ext); | |
| 44 | |
| 45 void DrawAndSwap(const gfx::Size& viewport, | |
| 46 const gfx::Rect& clip, | |
| 47 const gfx::Transform& transform, | |
| 48 const gfx::Size& frame_size, | |
| 49 const cc::SurfaceId& child_id, | |
| 50 const ScopedAppGLStateRestore& gl_state); | |
| 51 | |
| 52 void AddChildId(const cc::SurfaceId& child_id); | |
| 53 void RemoveChildId(const cc::SurfaceId& child_id); | |
| 54 | |
| 55 private: | |
| 56 friend class base::RefCounted<SurfacesInstance>; | |
| 57 | |
| 58 SurfacesInstance(); | |
| 59 ~SurfacesInstance() override; | |
| 60 | |
| 61 // cc::DisplayClient overrides. | |
| 62 void DisplayOutputSurfaceLost() override {} | |
| 63 void DisplaySetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override {} | |
| 64 | |
| 65 // cc::SurfaceFactoryClient implementation. | |
| 66 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | |
| 67 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | |
| 68 | |
| 69 void SetEmptyRootFrame(); | |
| 70 | |
| 71 uint32_t next_surface_id_namespace_; | |
| 72 | |
| 73 scoped_refptr<AwGLSurface> gl_surface_; | |
|
hush (inactive)
2016/06/29 00:03:12
why is this scoped_refptr while others are unique_
boliu
2016/06/29 01:01:04
GLSurface is refcounted. Can't mix refcounted and
| |
| 74 std::unique_ptr<cc::SurfaceManager> surface_manager_; | |
| 75 std::unique_ptr<cc::Display> display_; | |
| 76 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | |
| 77 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | |
| 78 | |
| 79 cc::SurfaceId root_id_; | |
| 80 std::vector<cc::SurfaceId> child_ids_; | |
| 81 | |
| 82 // This is owned by |display_|. | |
| 83 ParentOutputSurface* output_surface_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(SurfacesInstance); | |
| 86 }; | |
| 87 | |
| 88 } // namespace android_webview | |
| 89 | |
| 90 #endif // ANDROID_WEBVIEW_BROWSER_SURFACES_INSTANCE_H_ | |
| OLD | NEW |