Implement android_webview url intercepting.
[chromium-blink-merge.git] / cc / proxy.h
blobcae128e51abf826733da2dbdfb149470fa899d41
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
3 // found in the LICENSE file.
5 #ifndef CCProxy_h
6 #define CCProxy_h
8 #include "base/basictypes.h"
9 #include <public/WebCompositorOutputSurface.h>
11 namespace cc {
13 class CCThread;
14 class IntRect;
15 class IntSize;
16 struct CCRenderingStats;
17 struct RendererCapabilities;
19 // Abstract class responsible for proxying commands from the main-thread side of
20 // the compositor over to the compositor implementation.
21 class CCProxy {
22 public:
23 static void setMainThread(CCThread*);
24 static CCThread* mainThread();
26 static bool hasImplThread();
27 static void setImplThread(CCThread*);
28 static CCThread* implThread();
30 // Returns 0 if the current thread is neither the main thread nor the impl thread.
31 static CCThread* currentThread();
33 virtual ~CCProxy();
35 virtual bool compositeAndReadback(void *pixels, const IntRect&) = 0;
37 virtual void startPageScaleAnimation(const IntSize& targetPosition, bool useAnchor, float scale, double durationSec) = 0;
39 virtual void finishAllRendering() = 0;
41 virtual bool isStarted() const = 0;
43 // Attempts to initialize a context to use for rendering. Returns false if the context could not be created.
44 // The context will not be used and no frames may be produced until initializeRenderer() is called.
45 virtual bool initializeContext() = 0;
47 // Indicates that the compositing surface associated with our context is ready to use.
48 virtual void setSurfaceReady() = 0;
50 virtual void setVisible(bool) = 0;
52 // Attempts to initialize the layer renderer. Returns false if the context isn't usable for compositing.
53 virtual bool initializeRenderer() = 0;
55 // Attempts to recreate the context and layer renderer after a context lost. Returns false if the renderer couldn't be
56 // reinitialized.
57 virtual bool recreateContext() = 0;
59 virtual void renderingStats(CCRenderingStats*) = 0;
61 virtual const RendererCapabilities& rendererCapabilities() const = 0;
63 virtual void setNeedsAnimate() = 0;
64 virtual void setNeedsCommit() = 0;
65 virtual void setNeedsRedraw() = 0;
67 virtual void didAddAnimation() = 0;
69 virtual bool commitRequested() const = 0;
71 virtual void start() = 0; // Must be called before using the proxy.
72 virtual void stop() = 0; // Must be called before deleting the proxy.
74 // Forces 3D commands on all contexts to wait for all previous SwapBuffers to finish before executing in the GPU
75 // process.
76 virtual void forceSerializeOnSwapBuffers() = 0;
78 // Maximum number of sub-region texture updates supported for each commit.
79 virtual size_t maxPartialTextureUpdates() const = 0;
81 virtual void acquireLayerTextures() = 0;
83 // Debug hooks
84 #ifndef NDEBUG
85 static bool isMainThread();
86 static bool isImplThread();
87 static bool isMainThreadBlocked();
88 static void setMainThreadBlocked(bool);
89 #endif
91 // Testing hooks
92 virtual void loseContext() = 0;
94 #ifndef NDEBUG
95 static void setCurrentThreadIsImplThread(bool);
96 #endif
98 protected:
99 CCProxy();
100 friend class DebugScopedSetImplThread;
101 friend class DebugScopedSetMainThreadBlocked;
103 private:
104 DISALLOW_COPY_AND_ASSIGN(CCProxy);
107 class DebugScopedSetMainThreadBlocked {
108 public:
109 DebugScopedSetMainThreadBlocked()
111 #if !ASSERT_DISABLED
112 ASSERT(!CCProxy::isMainThreadBlocked());
113 CCProxy::setMainThreadBlocked(true);
114 #endif
116 ~DebugScopedSetMainThreadBlocked()
118 #if !ASSERT_DISABLED
119 ASSERT(CCProxy::isMainThreadBlocked());
120 CCProxy::setMainThreadBlocked(false);
121 #endif
127 #endif