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 #include "mojo/apps/js/bindings/gl/module.h" 6 7 #include <GLES2/gl2.h> 8 #include <GLES2/gl2ext.h> 9 10 #include "base/logging.h" 11 #include "gin/arguments.h" 12 #include "gin/object_template_builder.h" 13 #include "gin/per_isolate_data.h" 14 #include "gin/wrappable.h" 15 #include "mojo/apps/js/bindings/gl/context.h" 16 17 namespace mojo { 18 namespace js { 19 namespace gl { 20 21 const char* kModuleName = "mojo/apps/js/bindings/gl"; 22 23 namespace { 24 25 gin::WrapperInfo kWrapperInfo = { gin::kEmbedderNativeGin }; 26 27 gin::Handle<Context> CreateContext(const gin::Arguments& args, uint64_t encoded, 28 int width, int height) { 29 return Context::Create(args.isolate(), encoded, width, height); 30 } 31 32 } // namespace 33 34 v8::Local<v8::ObjectTemplate> GetModuleTemplate(v8::Isolate* isolate) { 35 gin::PerIsolateData* data = gin::PerIsolateData::From(isolate); 36 v8::Local<v8::ObjectTemplate> templ = data->GetObjectTemplate(&kWrapperInfo); 37 38 if (templ.IsEmpty()) { 39 templ = gin::ObjectTemplateBuilder(isolate) 40 .SetMethod("Context", CreateContext) 41 .Build(); 42 templ->SetInternalFieldCount(gin::kNumberOfInternalFields); 43 data->SetObjectTemplate(&kWrapperInfo, templ); 44 } 45 46 Context::GetObjectTemplate(isolate); 47 Opaque::GetObjectTemplate(isolate); 48 49 return templ; 50 } 51 52 } // namespace gl 53 } // namespace js 54 } // namespace mojo 55