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

Side by Side Diff: cc/layer_tree_host.h

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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
« no previous file with comments | « cc/layer_tiling_data.cc ('k') | cc/layer_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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
5 #ifndef CCLayerTreeHost_h
6 #define CCLayerTreeHost_h
7
8 #include "base/basictypes.h"
9 #include "base/hash_tables.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "CCAnimationEvents.h"
13 #include "CCGraphicsContext.h"
14 #include "CCLayerTreeHostClient.h"
15 #include "CCLayerTreeHostCommon.h"
16 #include "CCOcclusionTracker.h"
17 #include "CCPrioritizedTextureManager.h"
18 #include "CCProxy.h"
19 #include "CCRenderingStats.h"
20 #include "IntRect.h"
21 #include "RateLimiter.h"
22 #include "scoped_ptr_vector.h"
23 #include "SkColor.h"
24 #include <limits>
25
26 #if defined(COMPILER_GCC)
27 namespace BASE_HASH_NAMESPACE {
28 template<>
29 struct hash<WebKit::WebGraphicsContext3D*> {
30 size_t operator()(WebKit::WebGraphicsContext3D* ptr) const {
31 return hash<size_t>()(reinterpret_cast<size_t>(ptr));
32 }
33 };
34 } // namespace BASE_HASH_NAMESPACE
35 #endif // COMPILER
36
37 namespace cc {
38
39 class CCFontAtlas;
40 class CCLayerChromium;
41 class CCLayerTreeHostImpl;
42 class CCLayerTreeHostImplClient;
43 class CCPrioritizedTextureManager;
44 class CCTextureUpdateQueue;
45 class HeadsUpDisplayLayerChromium;
46 class Region;
47 struct CCScrollAndScaleSet;
48
49 struct CCLayerTreeSettings {
50 CCLayerTreeSettings();
51 ~CCLayerTreeSettings();
52
53 bool acceleratePainting;
54 bool showFPSCounter;
55 bool showPlatformLayerTree;
56 bool showPaintRects;
57 bool showPropertyChangedRects;
58 bool showSurfaceDamageRects;
59 bool showScreenSpaceRects;
60 bool showReplicaScreenSpaceRects;
61 bool showOccludingRects;
62 bool renderVSyncEnabled;
63 double refreshRate;
64 size_t maxPartialTextureUpdates;
65 IntSize defaultTileSize;
66 IntSize maxUntiledLayerSize;
67 IntSize minimumOcclusionTrackingSize;
68
69 bool showDebugInfo() const { return showPlatformLayerTree || showFPSCounter || showDebugRects(); }
70 bool showDebugRects() const { return showPaintRects || showPropertyChangedRe cts || showSurfaceDamageRects || showScreenSpaceRects || showReplicaScreenSpaceR ects || showOccludingRects; }
71 };
72
73 // Provides information on an Impl's rendering capabilities back to the CCLayerT reeHost
74 struct RendererCapabilities {
75 RendererCapabilities();
76 ~RendererCapabilities();
77
78 GC3Denum bestTextureFormat;
79 bool contextHasCachedFrontBuffer;
80 bool usingPartialSwap;
81 bool usingAcceleratedPainting;
82 bool usingSetVisibility;
83 bool usingSwapCompleteCallback;
84 bool usingGpuMemoryManager;
85 bool usingDiscardFramebuffer;
86 bool usingEglImage;
87 int maxTextureSize;
88 };
89
90 class CCLayerTreeHost : public RateLimiterClient {
91 public:
92 static scoped_ptr<CCLayerTreeHost> create(CCLayerTreeHostClient*, const CCLa yerTreeSettings&);
93 virtual ~CCLayerTreeHost();
94
95 void setSurfaceReady();
96
97 // Returns true if any CCLayerTreeHost is alive.
98 static bool anyLayerTreeHostInstanceExists();
99
100 static bool needsFilterContext() { return s_needsFilterContext; }
101 static void setNeedsFilterContext(bool needsFilterContext) { s_needsFilterCo ntext = needsFilterContext; }
102 bool needsSharedContext() const { return needsFilterContext() || settings(). acceleratePainting; }
103
104 // CCLayerTreeHost interface to CCProxy.
105 void willBeginFrame() { m_client->willBeginFrame(); }
106 void didBeginFrame() { m_client->didBeginFrame(); }
107 void updateAnimations(double monotonicFrameBeginTime);
108 void layout();
109 void beginCommitOnImplThread(CCLayerTreeHostImpl*);
110 void finishCommitOnImplThread(CCLayerTreeHostImpl*);
111 void willCommit();
112 void commitComplete();
113 scoped_ptr<CCGraphicsContext> createContext();
114 scoped_ptr<CCInputHandler> createInputHandler();
115 virtual scoped_ptr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeH ostImplClient*);
116 void didLoseContext();
117 enum RecreateResult {
118 RecreateSucceeded,
119 RecreateFailedButTryAgain,
120 RecreateFailedAndGaveUp,
121 };
122 RecreateResult recreateContext();
123 void didCommitAndDrawFrame() { m_client->didCommitAndDrawFrame(); }
124 void didCompleteSwapBuffers() { m_client->didCompleteSwapBuffers(); }
125 void deleteContentsTexturesOnImplThread(CCResourceProvider*);
126 virtual void acquireLayerTextures();
127 // Returns false if we should abort this frame due to initialization failure .
128 bool initializeRendererIfNeeded();
129 void updateLayers(CCTextureUpdateQueue&, size_t contentsMemoryLimitBytes);
130
131 CCLayerTreeHostClient* client() { return m_client; }
132
133 // Only used when compositing on the main thread.
134 void composite();
135 void scheduleComposite();
136
137 // Composites and attempts to read back the result into the provided
138 // buffer. If it wasn't possible, e.g. due to context lost, will return
139 // false.
140 bool compositeAndReadback(void *pixels, const IntRect&);
141
142 void finishAllRendering();
143
144 int commitNumber() const { return m_commitNumber; }
145
146 void renderingStats(CCRenderingStats*) const;
147
148 const RendererCapabilities& rendererCapabilities() const;
149
150 // Test only hook
151 void loseContext(int numTimes);
152
153 void setNeedsAnimate();
154 // virtual for testing
155 virtual void setNeedsCommit();
156 void setNeedsRedraw();
157 bool commitRequested() const;
158
159 void setAnimationEvents(scoped_ptr<CCAnimationEventsVector>, double wallCloc kTime);
160 virtual void didAddAnimation();
161
162 LayerChromium* rootLayer() { return m_rootLayer.get(); }
163 const LayerChromium* rootLayer() const { return m_rootLayer.get(); }
164 void setRootLayer(scoped_refptr<LayerChromium>);
165
166 const CCLayerTreeSettings& settings() const { return m_settings; }
167
168 void setViewportSize(const IntSize& layoutViewportSize, const IntSize& devic eViewportSize);
169
170 const IntSize& layoutViewportSize() const { return m_layoutViewportSize; }
171 const IntSize& deviceViewportSize() const { return m_deviceViewportSize; }
172
173 void setPageScaleFactorAndLimits(float pageScaleFactor, float minPageScaleFa ctor, float maxPageScaleFactor);
174
175 void setBackgroundColor(SkColor color) { m_backgroundColor = color; }
176
177 void setHasTransparentBackground(bool transparent) { m_hasTransparentBackgro und = transparent; }
178
179 CCPrioritizedTextureManager* contentsTextureManager() const;
180
181 // Delete contents textures' backing resources until they use only bytesLimi t bytes. This may
182 // be called on the impl thread while the main thread is running.
183 void reduceContentsTexturesMemoryOnImplThread(size_t bytesLimit, CCResourceP rovider*);
184 // Returns true if there any evicted backing textures that have not been del eted.
185 bool evictedContentsTexturesBackingsExist() const;
186 // Retrieve the list of all contents textures' backings that have been evict ed, to pass to the
187 // main thread to unlink them from their owning textures.
188 void getEvictedContentTexturesBackings(CCPrioritizedTextureManager::BackingV ector&);
189 // Unlink the list of contents textures' backings from their owning textures on the main thread
190 // before updating layers.
191 void unlinkEvictedContentTexturesBackings(const CCPrioritizedTextureManager: :BackingVector&);
192 // Deletes all evicted backings, unlinking them from their owning textures i f needed.
193 // Returns true if this function had to unlink any backings from their ownin g texture when
194 // destroying them. If this was the case, the impl layer tree may contain in valid resources.
195 bool deleteEvictedContentTexturesBackings();
196
197 bool visible() const { return m_visible; }
198 void setVisible(bool);
199
200 void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec);
201
202 void applyScrollAndScale(const CCScrollAndScaleSet&);
203 void setImplTransform(const WebKit::WebTransformationMatrix&);
204
205 void startRateLimiter(WebKit::WebGraphicsContext3D*);
206 void stopRateLimiter(WebKit::WebGraphicsContext3D*);
207
208 // RateLimitClient implementation
209 virtual void rateLimit() OVERRIDE;
210
211 bool bufferedUpdates();
212 bool requestPartialTextureUpdate();
213 void deleteTextureAfterCommit(scoped_ptr<CCPrioritizedTexture>);
214
215 void setDeviceScaleFactor(float);
216 float deviceScaleFactor() const { return m_deviceScaleFactor; }
217
218 void setFontAtlas(scoped_ptr<CCFontAtlas>);
219
220 HeadsUpDisplayLayerChromium* hudLayer() const { return m_hudLayer.get(); }
221
222 protected:
223 CCLayerTreeHost(CCLayerTreeHostClient*, const CCLayerTreeSettings&);
224 bool initialize();
225
226 private:
227 typedef std::vector<scoped_refptr<LayerChromium> > LayerList;
228
229 void initializeRenderer();
230
231 void update(LayerChromium*, CCTextureUpdateQueue&, const CCOcclusionTracker* );
232 bool paintLayerContents(const LayerList&, CCTextureUpdateQueue&);
233 bool paintMasksForRenderSurface(LayerChromium*, CCTextureUpdateQueue&);
234
235 void updateLayers(LayerChromium*, CCTextureUpdateQueue&);
236
237 void prioritizeTextures(const LayerList&, CCOverdrawMetrics&);
238 void setPrioritiesForSurfaces(size_t surfaceMemoryBytes);
239 void setPrioritiesForLayers(const LayerList&);
240 size_t calculateMemoryForRenderSurfaces(const LayerList& updateList);
241
242 void animateLayers(double monotonicTime);
243 bool animateLayersRecursive(LayerChromium* current, double monotonicTime);
244 void setAnimationEventsRecursive(const CCAnimationEventsVector&, LayerChromi um*, double wallClockTime);
245
246 bool m_animating;
247 bool m_needsAnimateLayers;
248
249 CCLayerTreeHostClient* m_client;
250
251 int m_commitNumber;
252 CCRenderingStats m_renderingStats;
253
254 scoped_ptr<CCProxy> m_proxy;
255 bool m_rendererInitialized;
256 bool m_contextLost;
257 int m_numTimesRecreateShouldFail;
258 int m_numFailedRecreateAttempts;
259
260 scoped_refptr<LayerChromium> m_rootLayer;
261 scoped_refptr<HeadsUpDisplayLayerChromium> m_hudLayer;
262 scoped_ptr<CCFontAtlas> m_fontAtlas;
263
264 scoped_ptr<CCPrioritizedTextureManager> m_contentsTextureManager;
265 scoped_ptr<CCPrioritizedTexture> m_surfaceMemoryPlaceholder;
266
267 CCLayerTreeSettings m_settings;
268
269 IntSize m_layoutViewportSize;
270 IntSize m_deviceViewportSize;
271 float m_deviceScaleFactor;
272
273 bool m_visible;
274
275 typedef base::hash_map<WebKit::WebGraphicsContext3D*, scoped_refptr<RateLimi ter> > RateLimiterMap;
276 RateLimiterMap m_rateLimiters;
277
278 float m_pageScaleFactor;
279 float m_minPageScaleFactor, m_maxPageScaleFactor;
280 WebKit::WebTransformationMatrix m_implTransform;
281 bool m_triggerIdleUpdates;
282
283 SkColor m_backgroundColor;
284 bool m_hasTransparentBackground;
285
286 typedef ScopedPtrVector<CCPrioritizedTexture> TextureList;
287 TextureList m_deleteTextureAfterCommitList;
288 size_t m_partialTextureUpdateRequests;
289
290 static bool s_needsFilterContext;
291
292 DISALLOW_COPY_AND_ASSIGN(CCLayerTreeHost);
293 };
294
295 } // namespace cc
296
297 #endif
OLDNEW
« no previous file with comments | « cc/layer_tiling_data.cc ('k') | cc/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698