| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ |
| 6 #define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "android_webview/browser/compositor_id.h" | 10 #include "android_webview/browser/compositor_id.h" |
| 11 #include "android_webview/browser/render_thread_manager.h" | |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 13 #include "cc/surfaces/display_client.h" | 12 #include "base/memory/ref_counted.h" |
| 14 #include "cc/surfaces/surface_factory_client.h" | 13 #include "cc/surfaces/surface_factory_client.h" |
| 15 #include "cc/surfaces/surface_id.h" | 14 #include "cc/surfaces/surface_id.h" |
| 16 | 15 |
| 17 struct AwDrawGLInfo; | 16 struct AwDrawGLInfo; |
| 18 | 17 |
| 19 namespace cc { | 18 namespace cc { |
| 20 class Display; | 19 class Display; |
| 21 class SurfaceFactory; | 20 class SurfaceFactory; |
| 22 class SurfaceIdAllocator; | 21 class SurfaceIdAllocator; |
| 23 class SurfaceManager; | 22 class SurfaceManager; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace android_webview { | 25 namespace android_webview { |
| 27 | 26 |
| 28 class AwGLSurface; | |
| 29 class ChildFrame; | 27 class ChildFrame; |
| 30 class ParentOutputSurface; | 28 class RenderThreadManager; |
| 31 class ScopedAppGLStateRestore; | 29 class ScopedAppGLStateRestore; |
| 30 class SurfacesInstance; |
| 32 | 31 |
| 33 class HardwareRenderer : public cc::DisplayClient, | 32 class HardwareRenderer : public cc::SurfaceFactoryClient { |
| 34 public cc::SurfaceFactoryClient { | |
| 35 public: | 33 public: |
| 36 explicit HardwareRenderer(RenderThreadManager* state); | 34 explicit HardwareRenderer(RenderThreadManager* state); |
| 37 ~HardwareRenderer() override; | 35 ~HardwareRenderer() override; |
| 38 | 36 |
| 39 void DrawGL(AwDrawGLInfo* draw_info, const ScopedAppGLStateRestore& gl_state); | 37 void DrawGL(AwDrawGLInfo* draw_info, const ScopedAppGLStateRestore& gl_state); |
| 40 void CommitFrame(); | 38 void CommitFrame(); |
| 41 | 39 |
| 42 void SetBackingFrameBufferObject(int framebuffer_binding_ext); | 40 void SetBackingFrameBufferObject(int framebuffer_binding_ext); |
| 43 | 41 |
| 44 private: | 42 private: |
| 45 // cc::DisplayClient overrides. | |
| 46 void DisplayOutputSurfaceLost() override {} | |
| 47 void DisplaySetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override {} | |
| 48 | |
| 49 // cc::SurfaceFactoryClient implementation. | 43 // cc::SurfaceFactoryClient implementation. |
| 50 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 44 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 51 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 45 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 52 | 46 |
| 53 void ReturnResourcesInChildFrame(); | 47 void ReturnResourcesInChildFrame(); |
| 54 void ReturnResourcesToCompositor(const cc::ReturnedResourceArray& resources, | 48 void ReturnResourcesToCompositor(const cc::ReturnedResourceArray& resources, |
| 55 const CompositorID& compositor_id, | 49 const CompositorID& compositor_id, |
| 56 uint32_t output_surface_id); | 50 uint32_t output_surface_id); |
| 57 | 51 |
| 52 void AllocateSurface(); |
| 53 void DestroySurface(); |
| 54 |
| 58 RenderThreadManager* render_thread_manager_; | 55 RenderThreadManager* render_thread_manager_; |
| 59 | 56 |
| 60 typedef void* EGLContext; | 57 typedef void* EGLContext; |
| 61 EGLContext last_egl_context_; | 58 EGLContext last_egl_context_; |
| 62 | 59 |
| 63 // Information about last delegated frame. | 60 // Information about last delegated frame. |
| 64 gfx::Size frame_size_; | 61 gfx::Size frame_size_; |
| 65 | 62 |
| 66 // Infromation from UI on last commit. | 63 // Infromation from UI on last commit. |
| 67 gfx::Vector2d scroll_offset_; | 64 gfx::Vector2d scroll_offset_; |
| 68 | 65 |
| 69 // This holds the last ChildFrame received. Contains the frame info of the | 66 // This holds the last ChildFrame received. Contains the frame info of the |
| 70 // last frame. The |frame| member may be null if it's already submitted to | 67 // last frame. The |frame| member may be null if it's already submitted to |
| 71 // SurfaceFactory. | 68 // SurfaceFactory. |
| 72 std::unique_ptr<ChildFrame> child_frame_; | 69 std::unique_ptr<ChildFrame> child_frame_; |
| 73 | 70 |
| 74 scoped_refptr<AwGLSurface> gl_surface_; | 71 const scoped_refptr<SurfacesInstance> surfaces_; |
| 75 | 72 const std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 76 std::unique_ptr<cc::SurfaceManager> surface_manager_; | |
| 77 std::unique_ptr<cc::Display> display_; | |
| 78 std::unique_ptr<cc::SurfaceFactory> surface_factory_; | 73 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
| 79 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | |
| 80 cc::SurfaceId child_id_; | 74 cc::SurfaceId child_id_; |
| 81 cc::SurfaceId root_id_; | |
| 82 CompositorID compositor_id_; | 75 CompositorID compositor_id_; |
| 83 // HardwareRenderer guarantees resources are returned in the order of | 76 // HardwareRenderer guarantees resources are returned in the order of |
| 84 // output_surface_id, and resources for old output surfaces are dropped. | 77 // output_surface_id, and resources for old output surfaces are dropped. |
| 85 uint32_t last_committed_output_surface_id_; | 78 uint32_t last_committed_output_surface_id_; |
| 86 uint32_t last_submitted_output_surface_id_; | 79 uint32_t last_submitted_output_surface_id_; |
| 87 | 80 |
| 88 // This is owned by |display_|. | |
| 89 ParentOutputSurface* output_surface_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); | 81 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); |
| 92 }; | 82 }; |
| 93 | 83 |
| 94 } // namespace android_webview | 84 } // namespace android_webview |
| 95 | 85 |
| 96 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ | 86 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ |
| OLD | NEW |