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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_
6 #define COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_
8 #include "base/macros.h"
9 #include "base/synchronization/lock.h"
10 #include "cc/output/context_provider.h"
11 #include "third_party/mojo/src/mojo/public/c/gles2/gles2.h"
12 #include "third_party/mojo/src/mojo/public/cpp/system/core.h"
16 class SurfacesContextProvider
: public cc::ContextProvider
{
18 explicit SurfacesContextProvider(
19 mojo::ScopedMessagePipeHandle command_buffer_handle
);
21 // cc::ContextProvider implementation.
22 bool BindToCurrentThread() override
;
23 gpu::gles2::GLES2Interface
* ContextGL() override
;
24 gpu::ContextSupport
* ContextSupport() override
;
25 class GrContext
* GrContext() override
;
26 void InvalidateGrContext(uint32_t state
) override
;
27 Capabilities
ContextCapabilities() override
;
28 void VerifyContexts() override
{}
29 void DeleteCachedResources() override
{}
30 bool DestroyedOnMainThread() override
;
31 void SetLostContextCallback(
32 const LostContextCallback
& lost_context_callback
) override
;
33 void SetMemoryPolicyChangedCallback(
34 const MemoryPolicyChangedCallback
& memory_policy_changed_callback
)
36 void SetupLock() override
;
37 base::Lock
* GetLock() override
;
40 friend class base::RefCountedThreadSafe
<SurfacesContextProvider
>;
41 ~SurfacesContextProvider() override
;
44 static void ContextLostThunk(void* closure
) {
45 static_cast<SurfacesContextProvider
*>(closure
)->ContextLost();
49 cc::ContextProvider::Capabilities capabilities_
;
50 mojo::ScopedMessagePipeHandle command_buffer_handle_
;
51 MojoGLES2Context context_
;
52 LostContextCallback lost_context_callback_
;
54 base::Lock context_lock_
;
56 DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider
);
59 } // namespace surfaces
61 #endif // COMPONENTS_VIEW_MANAGER_SURFACES_SURFACES_CONTEXT_PROVIDER_H_