mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
59 lines
2.0 KiB
JavaScript
59 lines
2.0 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
* Code distributed by Google as part of the polymer project is also
|
|
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
*/
|
|
|
|
(function(scope) {
|
|
'use strict';
|
|
|
|
var mixin = scope.mixin;
|
|
var registerWrapper = scope.registerWrapper;
|
|
var setWrapper = scope.setWrapper;
|
|
var unsafeUnwrap = scope.unsafeUnwrap;
|
|
var unwrapIfNeeded = scope.unwrapIfNeeded;
|
|
var wrap = scope.wrap;
|
|
|
|
var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
|
|
|
|
// IE10 does not have WebGL.
|
|
if (!OriginalWebGLRenderingContext)
|
|
return;
|
|
|
|
function WebGLRenderingContext(impl) {
|
|
setWrapper(impl, this);
|
|
}
|
|
|
|
mixin(WebGLRenderingContext.prototype, {
|
|
get canvas() {
|
|
return wrap(unsafeUnwrap(this).canvas);
|
|
},
|
|
|
|
texImage2D: function() {
|
|
arguments[5] = unwrapIfNeeded(arguments[5]);
|
|
unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments);
|
|
},
|
|
|
|
texSubImage2D: function() {
|
|
arguments[6] = unwrapIfNeeded(arguments[6]);
|
|
unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments);
|
|
}
|
|
});
|
|
|
|
// Blink/WebKit has broken DOM bindings. Usually we would create an instance
|
|
// of the object and pass it into registerWrapper as a "blueprint" but
|
|
// creating WebGL contexts is expensive and might fail so we use a dummy
|
|
// object with dummy instance properties for these broken browsers.
|
|
var instanceProperties = /WebKit/.test(navigator.userAgent) ?
|
|
{drawingBufferHeight: null, drawingBufferWidth: null} : {};
|
|
|
|
registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext,
|
|
instanceProperties);
|
|
|
|
scope.wrappers.WebGLRenderingContext = WebGLRenderingContext;
|
|
})(window.ShadowDOMPolyfill);
|