5dba92cc144f4d573c059ef69a0eae725f8432b5
[platform/framework/web/crosswalk.git] / src / mojo / examples / pepper_container_app / graphics_3d_resource.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 #ifndef MOJO_EXAMPLES_PEPPER_CONTAINER_APP_GRAPHICS_3D_RESOURCE_H_
6 #define MOJO_EXAMPLES_PEPPER_CONTAINER_APP_GRAPHICS_3D_RESOURCE_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "mojo/public/c/gles2/gles2_types.h"
11 #include "ppapi/shared_impl/resource.h"
12 #include "ppapi/shared_impl/tracked_callback.h"
13 #include "ppapi/thunk/ppb_graphics_3d_api.h"
14
15 namespace mojo {
16 namespace examples {
17
18 class Graphics3DResource : public ppapi::Resource,
19                            public ppapi::thunk::PPB_Graphics3D_API {
20  public:
21   explicit Graphics3DResource(PP_Instance instance);
22
23   bool IsBoundGraphics() const;
24   void BindGraphics();
25
26   // ppapi::Resource overrides.
27   virtual ppapi::thunk::PPB_Graphics3D_API* AsPPB_Graphics3D_API() OVERRIDE;
28
29   // ppapi::thunk::PPB_Graphics3D_API implementation.
30   virtual int32_t GetAttribs(int32_t attrib_list[]) OVERRIDE;
31   virtual int32_t SetAttribs(const int32_t attrib_list[]) OVERRIDE;
32   virtual int32_t GetError() OVERRIDE;
33   virtual int32_t ResizeBuffers(int32_t width, int32_t height) OVERRIDE;
34   virtual int32_t SwapBuffers(
35       scoped_refptr<ppapi::TrackedCallback> callback) OVERRIDE;
36   virtual int32_t GetAttribMaxValue(int32_t attribute, int32_t* value) OVERRIDE;
37   virtual PP_Bool SetGetBuffer(int32_t shm_id) OVERRIDE;
38   virtual scoped_refptr<gpu::Buffer> CreateTransferBuffer(uint32_t size,
39                                                           int32* id) OVERRIDE;
40   virtual PP_Bool DestroyTransferBuffer(int32_t id) OVERRIDE;
41   virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
42   virtual gpu::CommandBuffer::State WaitForTokenInRange(int32_t start,
43                                                         int32_t end) OVERRIDE;
44   virtual gpu::CommandBuffer::State WaitForGetOffsetInRange(
45       int32_t start, int32_t end) OVERRIDE;
46   virtual void* MapTexSubImage2DCHROMIUM(GLenum target,
47                                          GLint level,
48                                          GLint xoffset,
49                                          GLint yoffset,
50                                          GLsizei width,
51                                          GLsizei height,
52                                          GLenum format,
53                                          GLenum type,
54                                          GLenum access) OVERRIDE;
55   virtual void UnmapTexSubImage2DCHROMIUM(const void* mem) OVERRIDE;
56   virtual uint32_t InsertSyncPoint() OVERRIDE;
57
58  private:
59   virtual ~Graphics3DResource();
60
61   static void ContextLostThunk(void* closure);
62   static void DrawAnimationFrameThunk(void* closure);
63   void ContextLost();
64
65   MojoGLES2Context context_;
66   DISALLOW_COPY_AND_ASSIGN(Graphics3DResource);
67 };
68
69 }  // namespace examples
70 }  // namespace mojo
71
72 #endif  // MOJO_EXAMPLES_PEPPER_CONTAINER_APP_GRAPHICS_3D_RESOURCE_H_