Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.h

Issue 239963002: Android: Move scheduling logic to CompositorImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
12 #include "cc/resources/ui_resource_client.h" 13 #include "cc/resources/ui_resource_client.h"
13 #include "cc/trees/layer_tree_host_client.h" 14 #include "cc/trees/layer_tree_host_client.h"
14 #include "cc/trees/layer_tree_host_single_thread_client.h" 15 #include "cc/trees/layer_tree_host_single_thread_client.h"
15 #include "content/browser/renderer_host/image_transport_factory_android.h" 16 #include "content/browser/renderer_host/image_transport_factory_android.h"
16 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
17 #include "content/public/browser/android/compositor.h" 18 #include "content/public/browser/android/compositor.h"
18 #include "third_party/khronos/GLES2/gl2.h" 19 #include "third_party/khronos/GLES2/gl2.h"
19 #include "ui/base/android/window_android_compositor.h" 20 #include "ui/base/android/window_android_compositor.h"
20 21
21 class SkBitmap; 22 class SkBitmap;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Compositor implementation. 57 // Compositor implementation.
57 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE; 58 virtual void SetRootLayer(scoped_refptr<cc::Layer> root) OVERRIDE;
58 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE; 59 virtual void SetWindowSurface(ANativeWindow* window) OVERRIDE;
59 virtual void SetSurface(jobject surface) OVERRIDE; 60 virtual void SetSurface(jobject surface) OVERRIDE;
60 virtual void SetVisible(bool visible) OVERRIDE; 61 virtual void SetVisible(bool visible) OVERRIDE;
61 virtual void setDeviceScaleFactor(float factor) OVERRIDE; 62 virtual void setDeviceScaleFactor(float factor) OVERRIDE;
62 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE; 63 virtual void SetWindowBounds(const gfx::Size& size) OVERRIDE;
63 virtual void SetHasTransparentBackground(bool flag) OVERRIDE; 64 virtual void SetHasTransparentBackground(bool flag) OVERRIDE;
64 virtual bool CompositeAndReadback( 65 virtual bool CompositeAndReadback(
65 void *pixels, const gfx::Rect& rect) OVERRIDE; 66 void *pixels, const gfx::Rect& rect) OVERRIDE;
66 virtual void Composite() OVERRIDE; 67 virtual void SetNeedsComposite() OVERRIDE;
67 virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, 68 virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap,
68 bool is_transient) OVERRIDE; 69 bool is_transient) OVERRIDE;
69 virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size, 70 virtual cc::UIResourceId GenerateCompressedUIResource(const gfx::Size& size,
70 void* pixels, 71 void* pixels,
71 bool is_transient) 72 bool is_transient)
72 OVERRIDE; 73 OVERRIDE;
73 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; 74 virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE;
74 75
75 // LayerTreeHostClient implementation. 76 // LayerTreeHostClient implementation.
76 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {} 77 virtual void WillBeginMainFrame(int frame_id) OVERRIDE {}
77 virtual void DidBeginMainFrame() OVERRIDE {} 78 virtual void DidBeginMainFrame() OVERRIDE {}
78 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {} 79 virtual void Animate(base::TimeTicks frame_begin_time) OVERRIDE {}
79 virtual void Layout() OVERRIDE {} 80 virtual void Layout() OVERRIDE;
80 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta, 81 virtual void ApplyScrollAndScale(const gfx::Vector2d& scroll_delta,
81 float page_scale) OVERRIDE {} 82 float page_scale) OVERRIDE {}
82 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) 83 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback)
83 OVERRIDE; 84 OVERRIDE;
84 virtual void DidInitializeOutputSurface() OVERRIDE {} 85 virtual void DidInitializeOutputSurface() OVERRIDE {}
85 virtual void WillCommit() OVERRIDE {} 86 virtual void WillCommit() OVERRIDE {}
86 virtual void DidCommit() OVERRIDE; 87 virtual void DidCommit() OVERRIDE;
87 virtual void DidCommitAndDrawFrame() OVERRIDE {} 88 virtual void DidCommitAndDrawFrame() OVERRIDE {}
88 virtual void DidCompleteSwapBuffers() OVERRIDE; 89 virtual void DidCompleteSwapBuffers() OVERRIDE;
89 90
90 // LayerTreeHostSingleThreadClient implementation. 91 // LayerTreeHostSingleThreadClient implementation.
91 virtual void ScheduleComposite() OVERRIDE; 92 virtual void ScheduleComposite() OVERRIDE;
92 virtual void ScheduleAnimation() OVERRIDE; 93 virtual void ScheduleAnimation() OVERRIDE;
93 virtual void DidPostSwapBuffers() OVERRIDE; 94 virtual void DidPostSwapBuffers() OVERRIDE;
94 virtual void DidAbortSwapBuffers() OVERRIDE; 95 virtual void DidAbortSwapBuffers() OVERRIDE;
95 96
96 // ImageTransportFactoryAndroidObserver implementation. 97 // ImageTransportFactoryAndroidObserver implementation.
97 virtual void OnLostResources() OVERRIDE; 98 virtual void OnLostResources() OVERRIDE;
98 99
99 // WindowAndroidCompositor implementation. 100 // WindowAndroidCompositor implementation.
100 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE; 101 virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) OVERRIDE;
102 virtual void OnVSync(base::TimeTicks frame_time,
103 base::TimeDelta vsync_period) OVERRIDE;
101 104
102 private: 105 private:
106 void PostComposite(base::TimeDelta delay);
107 void Composite(bool is_vsync);
Sami 2014/05/09 13:21:14 Mind making this an enum -- CompositingTrigger or
no sievers 2014/05/09 22:53:44 Done.
103 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( 108 cc::UIResourceId GenerateUIResourceFromUIResourceBitmap(
104 const cc::UIResourceBitmap& bitmap, 109 const cc::UIResourceBitmap& bitmap,
105 bool is_transient); 110 bool is_transient);
106 111
107 scoped_refptr<cc::Layer> root_layer_; 112 scoped_refptr<cc::Layer> root_layer_;
108 scoped_ptr<cc::LayerTreeHost> host_; 113 scoped_ptr<cc::LayerTreeHost> host_;
109 114
110 gfx::Size size_; 115 gfx::Size size_;
111 bool has_transparent_background_; 116 bool has_transparent_background_;
112 float device_scale_factor_; 117 float device_scale_factor_;
113 118
114 ANativeWindow* window_; 119 ANativeWindow* window_;
115 int surface_id_; 120 int surface_id_;
116 121
117 CompositorClient* client_; 122 CompositorClient* client_;
118 123
119 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> 124 typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient>
120 UIResourceMap; 125 UIResourceMap;
121 UIResourceMap ui_resource_map_; 126 UIResourceMap ui_resource_map_;
122 127
123 gfx::NativeWindow root_window_; 128 gfx::NativeWindow root_window_;
124 129
130 // Used locally to track whether a call to LTH::Composite() did result in
131 // a posted SwapBuffers().
132 bool did_post_swapbuffers_;
133
134 // Used locally to inhibit ScheduleComposite() during Layout().
135 bool ignore_schedule_composite_;
136
137 // Whether we need to composite in general because of any invalidation or
138 // explicit request.
139 bool needs_composite_;
140
141 // When SetNeedsComposite() is getting called, we will try to schedule
Sami 2014/05/09 13:21:14 This explanation should probably go next to SetNee
no sievers 2014/05/09 22:53:44 ScheduleComposite is the LTHClient implementation.
142 // regularly during vsync.
143 bool should_composite_on_vsync_;
144
145 // Whether we composited immediately outside of a vsync callback since
146 // the last tick.
147 bool did_composite_outside_vsync_;
Sami 2014/05/09 13:21:14 Would something did_composite_during_this_frame_ b
no sievers 2014/05/09 22:53:44 Done.
148
149 // The number of SwapBuffer calls that have not returned and ACK'd from
150 // the GPU thread.
151 unsigned int pending_swapbuffers_;
152
153 base::TimeDelta vsync_period_;
154
155 base::WeakPtrFactory<CompositorImpl> weak_factory_;
156
125 DISALLOW_COPY_AND_ASSIGN(CompositorImpl); 157 DISALLOW_COPY_AND_ASSIGN(CompositorImpl);
126 }; 158 };
127 159
128 } // namespace content 160 } // namespace content
129 161
130 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_ 162 #endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITOR_IMPL_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698