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

Side by Side Diff: cc/output/context_provider.h

Issue 20185002: ContextProvider in OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: contextprovider: don't access Context3d() in OutputSurface contructors, it's not bound yet Created 7 years, 4 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/layers/video_layer_impl.cc ('k') | cc/output/delegating_renderer.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 CC_OUTPUT_CONTEXT_PROVIDER_H_ 5 #ifndef CC_OUTPUT_CONTEXT_PROVIDER_H_
6 #define CC_OUTPUT_CONTEXT_PROVIDER_H_ 6 #define CC_OUTPUT_CONTEXT_PROVIDER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 10
11 class GrContext; 11 class GrContext;
12 namespace WebKit { class WebGraphicsContext3D; } 12 namespace WebKit { class WebGraphicsContext3D; }
13 13
14 namespace cc { 14 namespace cc {
15 struct ManagedMemoryPolicy;
15 16
16 class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { 17 class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
17 public: 18 public:
18 // Bind the 3d context to the current thread. This should be called before 19 // Bind the 3d context to the current thread. This should be called before
19 // accessing the contexts. Calling it more than once should have no effect. 20 // accessing the contexts. Calling it more than once should have no effect.
20 // Once this function has been called, the class should only be accessed 21 // Once this function has been called, the class should only be accessed
21 // from the same thread. 22 // from the same thread.
22 virtual bool BindToCurrentThread() = 0; 23 virtual bool BindToCurrentThread() = 0;
23 24
24 virtual WebKit::WebGraphicsContext3D* Context3d() = 0; 25 virtual WebKit::WebGraphicsContext3D* Context3d() = 0;
25 virtual class GrContext* GrContext() = 0; 26 virtual class GrContext* GrContext() = 0;
26 27
27 // Ask the provider to check if the contexts are valid or lost. If they are, 28 // Ask the provider to check if the contexts are valid or lost. If they are,
28 // this should invalidate the provider so that it can be replaced with a new 29 // this should invalidate the provider so that it can be replaced with a new
29 // one. 30 // one.
30 virtual void VerifyContexts() = 0; 31 virtual void VerifyContexts() = 0;
31 32
32 // A method to be called from the main thread that should return true if 33 // A method to be called from the main thread that should return true if
33 // the context inside the provider is no longer valid. 34 // the context inside the provider is no longer valid.
34 virtual bool DestroyedOnMainThread() = 0; 35 virtual bool DestroyedOnMainThread() = 0;
35 36
36 // Sets a callback to be called when the context is lost. This should be 37 // Sets a callback to be called when the context is lost. This should be
37 // called from the same thread that the context is bound to. To avoid races, 38 // called from the same thread that the context is bound to. To avoid races,
38 // it should be called before BindToCurrentThread(), or VerifyContexts() 39 // it should be called before BindToCurrentThread(), or VerifyContexts()
39 // should be called after setting the callback. 40 // should be called after setting the callback.
40 typedef base::Closure LostContextCallback; 41 typedef base::Closure LostContextCallback;
41 virtual void SetLostContextCallback( 42 virtual void SetLostContextCallback(
42 const LostContextCallback& lost_context_callback) = 0; 43 const LostContextCallback& lost_context_callback) = 0;
43 44
45 // Sets a callback to be called when the context is lost. This should be
46 // called from the same thread that the context is bound to.
47 typedef base::Closure SwapBuffersCompleteCallback;
48 virtual void SetSwapBuffersCompleteCallback(
49 const SwapBuffersCompleteCallback& swap_buffers_complete_callback) = 0;
50
51 // Sets a callback to be called when the memory policy changes. This should be
52 // called from the same thread that the context is bound to.
53 typedef base::Callback<void(
54 const cc::ManagedMemoryPolicy& policy,
55 bool discard_backbuffer_when_not_visible)> MemoryPolicyChangedCallback;
56 virtual void SetMemoryPolicyChangedCallback(
57 const MemoryPolicyChangedCallback& memory_policy_changed_callback) = 0;
58
44 protected: 59 protected:
45 friend class base::RefCountedThreadSafe<ContextProvider>; 60 friend class base::RefCountedThreadSafe<ContextProvider>;
46 virtual ~ContextProvider() {} 61 virtual ~ContextProvider() {}
47 }; 62 };
48 63
49 } // namespace cc 64 } // namespace cc
50 65
51 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ 66 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/layers/video_layer_impl.cc ('k') | cc/output/delegating_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698