Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / mojo / examples / compositor_app / mojo_context_provider.h
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.
4
5 #include "cc/output/context_provider.h"
6 #include "mojo/public/gles2/gles2.h"
7 #include "mojo/public/system/core_cpp.h"
8
9 namespace mojo {
10 namespace examples {
11
12 class MojoContextProvider : public cc::ContextProvider {
13  public:
14   explicit MojoContextProvider(ScopedMessagePipeHandle gl_pipe);
15
16   // cc::ContextProvider implementation.
17   virtual bool BindToCurrentThread() OVERRIDE;
18   virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE;
19   virtual gpu::ContextSupport* ContextSupport() OVERRIDE;
20   virtual class GrContext* GrContext() OVERRIDE;
21   virtual Capabilities ContextCapabilities() OVERRIDE;
22   virtual bool IsContextLost() OVERRIDE;
23   virtual void VerifyContexts() OVERRIDE {}
24   virtual bool DestroyedOnMainThread() OVERRIDE;
25   virtual void SetLostContextCallback(
26       const LostContextCallback& lost_context_callback) OVERRIDE {}
27   virtual void SetMemoryPolicyChangedCallback(
28       const MemoryPolicyChangedCallback& memory_policy_changed_callback)
29       OVERRIDE {}
30
31  protected:
32   friend class base::RefCountedThreadSafe<MojoContextProvider>;
33   virtual ~MojoContextProvider();
34
35  private:
36   static void ContextLostThunk(void* closure) {
37     static_cast<MojoContextProvider*>(closure)->ContextLost();
38   }
39   void ContextLost();
40
41   cc::ContextProvider::Capabilities capabilities_;
42   ScopedMessagePipeHandle gl_pipe_;
43   MojoGLES2Context context_;
44 };
45
46 }  // namespace examples
47 }  // namespace mojo