| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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_APPS_JS_BINDINGS_GL_CONTEXT_H_ | |
| 6 #define MOJO_APPS_JS_BINDINGS_GL_CONTEXT_H_ | |
| 7 | |
| 8 #include <GLES2/gl2.h> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "gin/handle.h" | |
| 12 #include "gin/public/wrapper_info.h" | |
| 13 #include "gin/runner.h" | |
| 14 #include "gin/wrappable.h" | |
| 15 #include "mojo/bindings/js/handle.h" | |
| 16 #include "mojo/public/c/gles2/gles2.h" | |
| 17 #include "v8/include/v8.h" | |
| 18 | |
| 19 namespace gin { | |
| 20 class Arguments; | |
| 21 class ArrayBufferView; | |
| 22 } | |
| 23 | |
| 24 namespace mojo { | |
| 25 namespace js { | |
| 26 namespace gl { | |
| 27 | |
| 28 // Context implements WebGLRenderingContext. | |
| 29 class Context : public gin::Wrappable<Context> { | |
| 30 public: | |
| 31 static gin::WrapperInfo kWrapperInfo; | |
| 32 | |
| 33 // TODO(piman): draw animation frame callback. | |
| 34 static gin::Handle<Context> Create( | |
| 35 v8::Isolate* isolate, | |
| 36 mojo::Handle handle, | |
| 37 v8::Handle<v8::Function> context_lost_callback); | |
| 38 | |
| 39 static void BufferData(GLenum target, const gin::ArrayBufferView& buffer, | |
| 40 GLenum usage); | |
| 41 static void CompileShader(const gin::Arguments& args, GLuint shader); | |
| 42 static GLuint CreateBuffer(); | |
| 43 static void DrawElements(GLenum mode, GLsizei count, GLenum type, | |
| 44 uint64_t indices); | |
| 45 static GLint GetAttribLocation(GLuint program, const std::string& name); | |
| 46 static std::string GetProgramInfoLog(GLuint program); | |
| 47 static std::string GetShaderInfoLog(GLuint shader); | |
| 48 static GLint GetUniformLocation(GLuint program, const std::string& name); | |
| 49 static void ShaderSource(GLuint shader, const std::string& source); | |
| 50 static void UniformMatrix4fv(GLint location, GLboolean transpose, | |
| 51 const gin::ArrayBufferView& buffer); | |
| 52 static void VertexAttribPointer(GLuint index, GLint size, GLenum type, | |
| 53 GLboolean normalized, GLsizei stride, | |
| 54 uint64_t offset); | |
| 55 | |
| 56 private: | |
| 57 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | |
| 58 v8::Isolate* isolate) override; | |
| 59 | |
| 60 explicit Context(v8::Isolate* isolate, | |
| 61 mojo::Handle handle, | |
| 62 v8::Handle<v8::Function> context_lost_callback); | |
| 63 ~Context() override; | |
| 64 | |
| 65 void ContextLost(); | |
| 66 static void ContextLostThunk(void* closure); | |
| 67 | |
| 68 base::WeakPtr<gin::Runner> runner_; | |
| 69 v8::Persistent<v8::Function> context_lost_callback_; | |
| 70 MojoGLES2Context context_; | |
| 71 }; | |
| 72 | |
| 73 } // namespace gl | |
| 74 } // namespace js | |
| 75 } // namespace mojo | |
| 76 | |
| 77 #endif // MOJO_APPS_JS_BINDINGS_GL_CONTEXT_H_ | |
| OLD | NEW |