| 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" | 11 #include "android_webview/browser/render_thread_manager.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "cc/surfaces/display_client.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; | |
| 31 class ScopedAppGLStateRestore; | 28 class ScopedAppGLStateRestore; |
| 29 class SurfacesInstance; |
| 32 | 30 |
| 33 class HardwareRenderer : public cc::DisplayClient, | 31 class HardwareRenderer : public cc::SurfaceFactoryClient { |
| 34 public cc::SurfaceFactoryClient { | |
| 35 public: | 32 public: |
| 36 explicit HardwareRenderer(RenderThreadManager* state); | 33 explicit HardwareRenderer(RenderThreadManager* state); |
| 37 ~HardwareRenderer() override; | 34 ~HardwareRenderer() override; |
| 38 | 35 |
| 39 void DrawGL(AwDrawGLInfo* draw_info, const ScopedAppGLStateRestore& gl_state); | 36 void DrawGL(AwDrawGLInfo* draw_info, const ScopedAppGLStateRestore& gl_state); |
| 40 void CommitFrame(); | 37 void CommitFrame(); |
| 41 | 38 |
| 42 void SetBackingFrameBufferObject(int framebuffer_binding_ext); | 39 void SetBackingFrameBufferObject(int framebuffer_binding_ext); |
| 43 | 40 |
| 44 private: | 41 private: |
| 45 // cc::DisplayClient overrides. | |
| 46 void DisplayOutputSurfaceLost() override {} | |
| 47 void DisplaySetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override {} | |
| 48 | |
| 49 // cc::SurfaceFactoryClient implementation. | 42 // cc::SurfaceFactoryClient implementation. |
| 50 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 43 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 51 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 44 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 52 | 45 |
| 53 void ReturnResourcesInChildFrame(); | 46 void ReturnResourcesInChildFrame(); |
| 54 void ReturnResourcesToCompositor(const cc::ReturnedResourceArray& resources, | 47 void ReturnResourcesToCompositor(const cc::ReturnedResourceArray& resources, |
| 55 const CompositorID& compositor_id, | 48 const CompositorID& compositor_id, |
| 56 uint32_t output_surface_id); | 49 uint32_t output_surface_id); |
| 57 | 50 |
| 58 RenderThreadManager* render_thread_manager_; | 51 RenderThreadManager* render_thread_manager_; |
| 59 | 52 |
| 60 typedef void* EGLContext; | 53 typedef void* EGLContext; |
| 61 EGLContext last_egl_context_; | 54 EGLContext last_egl_context_; |
| 62 | 55 |
| 63 // Information about last delegated frame. | 56 // Information about last delegated frame. |
| 64 gfx::Size frame_size_; | 57 gfx::Size frame_size_; |
| 65 | 58 |
| 66 // Infromation from UI on last commit. | 59 // Infromation from UI on last commit. |
| 67 gfx::Vector2d scroll_offset_; | 60 gfx::Vector2d scroll_offset_; |
| 68 | 61 |
| 69 // This holds the last ChildFrame received. Contains the frame info of the | 62 // 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 | 63 // last frame. The |frame| member may be null if it's already submitted to |
| 71 // SurfaceFactory. | 64 // SurfaceFactory. |
| 72 std::unique_ptr<ChildFrame> child_frame_; | 65 std::unique_ptr<ChildFrame> child_frame_; |
| 73 | 66 |
| 74 scoped_refptr<AwGLSurface> gl_surface_; | 67 scoped_refptr<SurfacesInstance> surfaces_; |
| 75 | 68 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_; | 69 std::unique_ptr<cc::SurfaceFactory> surface_factory_; |
| 79 std::unique_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; | |
| 80 cc::SurfaceId child_id_; | 70 cc::SurfaceId child_id_; |
| 81 cc::SurfaceId root_id_; | |
| 82 CompositorID compositor_id_; | 71 CompositorID compositor_id_; |
| 83 // HardwareRenderer guarantees resources are returned in the order of | 72 // HardwareRenderer guarantees resources are returned in the order of |
| 84 // output_surface_id, and resources for old output surfaces are dropped. | 73 // output_surface_id, and resources for old output surfaces are dropped. |
| 85 uint32_t last_committed_output_surface_id_; | 74 uint32_t last_committed_output_surface_id_; |
| 86 uint32_t last_submitted_output_surface_id_; | 75 uint32_t last_submitted_output_surface_id_; |
| 87 | 76 |
| 88 // This is owned by |display_|. | |
| 89 ParentOutputSurface* output_surface_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); | 77 DISALLOW_COPY_AND_ASSIGN(HardwareRenderer); |
| 92 }; | 78 }; |
| 93 | 79 |
| 94 } // namespace android_webview | 80 } // namespace android_webview |
| 95 | 81 |
| 96 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ | 82 #endif // ANDROID_WEBVIEW_BROWSER_HARDWARE_RENDERER_H_ |
| OLD | NEW |