Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp

Issue 24096029: Moved the majority of WebGL functionality into WebGLRenderingContextBase (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp
diff --git a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp
similarity index 85%
rename from Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
rename to Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp
index b048ba1ae71cde6ad1e6ddea2ffb590ff0149977..97205711931304d35d6bf1fe73093eee86a60636 100644
--- a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/Source/bindings/v8/custom/V8WebGLRenderingContextBaseCustom.cpp
@@ -29,7 +29,7 @@
*/
#include "config.h"
-#include "V8WebGLRenderingContext.h"
+#include "V8WebGLRenderingContextBase.h"
#include "V8ANGLEInstancedArrays.h"
#include "V8EXTFragDepth.h"
@@ -72,7 +72,7 @@
#include "bindings/v8/custom/V8Uint32ArrayCustom.h"
#include "bindings/v8/custom/V8Uint8ArrayCustom.h"
#include "core/dom/ExceptionCode.h"
-#include "core/html/canvas/WebGLRenderingContext.h"
+#include "core/html/canvas/WebGLRenderingContextBase.h"
#include "core/platform/NotImplemented.h"
#include "wtf/FastMalloc.h"
#include <limits>
@@ -80,7 +80,7 @@
namespace WebCore {
// Allocates new storage via fastMalloc.
-// Returns NULL if array failed to convert for any reason.
+// Returns 0 if array failed to convert for any reason.
static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len)
{
// Convert the data element-by-element.
@@ -100,7 +100,7 @@ static float* jsArrayToFloatArray(v8::Handle<v8::Array> array, uint32_t len)
}
// Allocates new storage via fastMalloc.
-// Returns NULL if array failed to convert for any reason.
+// Returns 0 if array failed to convert for any reason.
static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len)
{
// Convert the data element-by-element.
@@ -266,7 +266,7 @@ static void getObjectParameter(const v8::FunctionCallbackInfo<v8::Value>& args,
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
unsigned target = toInt32(args[0]);
unsigned pname = toInt32(args[1]);
WebGLGetInfo info;
@@ -306,14 +306,14 @@ enum WhichProgramCall {
kProgramParameter, kUniform
};
-void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getAttachedShadersMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() < 1) {
throwNotEnoughArgumentsError(args.GetIsolate());
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
throwTypeError(args.GetIsolate());
return;
@@ -331,14 +331,14 @@ void V8WebGLRenderingContext::getAttachedShadersMethodCustom(const v8::FunctionC
v8SetReturnValue(args, array);
}
-void V8WebGLRenderingContext::getBufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getBufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
getObjectParameter(args, kBuffer);
}
-void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getExtensionMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
- WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(args.Holder());
if (args.Length() < 1) {
throwNotEnoughArgumentsError(args.GetIsolate());
return;
@@ -348,14 +348,14 @@ void V8WebGLRenderingContext::getExtensionMethodCustom(const v8::FunctionCallbac
v8SetReturnValue(args, toV8Object(extension.get(), args.Holder(), args.GetIsolate()));
}
-void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getFramebufferAttachmentParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() != 3) {
throwNotEnoughArgumentsError(args.GetIsolate());
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
unsigned target = toInt32(args[0]);
unsigned attachment = toInt32(args[1]);
unsigned pname = toInt32(args[2]);
@@ -363,27 +363,27 @@ void V8WebGLRenderingContext::getFramebufferAttachmentParameterMethodCustom(cons
v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
}
-void V8WebGLRenderingContext::getParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() != 1) {
throwNotEnoughArgumentsError(args.GetIsolate());
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
unsigned pname = toInt32(args[0]);
WebGLGetInfo info = context->getParameter(pname);
v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
}
-void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getProgramParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() != 2) {
throwNotEnoughArgumentsError(args.GetIsolate());
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
throwTypeError(args.GetIsolate());
return;
@@ -394,19 +394,19 @@ void V8WebGLRenderingContext::getProgramParameterMethodCustom(const v8::Function
v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
}
-void V8WebGLRenderingContext::getRenderbufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getRenderbufferParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
getObjectParameter(args, kRenderbuffer);
}
-void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getShaderParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() != 2) {
throwNotEnoughArgumentsError(args.GetIsolate());
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
throwTypeError(args.GetIsolate());
return;
@@ -417,9 +417,9 @@ void V8WebGLRenderingContext::getShaderParameterMethodCustom(const v8::FunctionC
v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
}
-void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getSupportedExtensionsMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
- WebGLRenderingContext* imp = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* imp = V8WebGLRenderingContextBase::toNative(args.Holder());
if (imp->isContextLost()) {
v8SetReturnValueNull(args);
return;
@@ -432,19 +432,19 @@ void V8WebGLRenderingContext::getSupportedExtensionsMethodCustom(const v8::Funct
v8SetReturnValue(args, array);
}
-void V8WebGLRenderingContext::getTexParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getTexParameterMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
getObjectParameter(args, kTexture);
}
-void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getUniformMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
if (args.Length() != 2) {
throwNotEnoughArgumentsError(args.GetIsolate());
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
throwTypeError(args.GetIsolate());
return;
@@ -462,7 +462,7 @@ void V8WebGLRenderingContext::getUniformMethodCustom(const v8::FunctionCallbackI
v8SetReturnValue(args, toV8Object(info, args.Holder(), args.GetIsolate()));
}
-void V8WebGLRenderingContext::getVertexAttribMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::getVertexAttribMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
getObjectParameter(args, kVertexAttrib);
}
@@ -515,9 +515,9 @@ static void vertexAttribAndUniformHelperf(const v8::FunctionCallbackInfo<v8::Val
int index = -1;
WebGLUniformLocation* location = 0;
- if (isFunctionToCallForAttribute(functionToCall))
+ if (isFunctionToCallForAttribute(functionToCall)) {
index = toInt32(args[0]);
- else {
+ } else {
if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
throwTypeError(args.GetIsolate());
return;
@@ -525,11 +525,11 @@ static void vertexAttribAndUniformHelperf(const v8::FunctionCallbackInfo<v8::Val
location = toWebGLUniformLocation(args[0], ok, args.GetIsolate());
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
if (V8Float32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) {
Float32Array* array = V8Float32Array::toNative(args[1]->ToObject());
- ASSERT(array != NULL);
+ ASSERT(array);
switch (functionToCall) {
case kUniform1v: context->uniform1fv(location, array); break;
case kUniform2v: context->uniform2fv(location, array); break;
@@ -548,8 +548,7 @@ static void vertexAttribAndUniformHelperf(const v8::FunctionCallbackInfo<v8::Val
throwTypeError(args.GetIsolate());
return;
}
- v8::Handle<v8::Array> array =
- v8::Local<v8::Array>::Cast(args[1]);
+ v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]);
uint32_t len = array->Length();
float* data = jsArrayToFloatArray(array, len);
if (!data) {
@@ -588,7 +587,7 @@ static void uniformHelperi(const v8::FunctionCallbackInfo<v8::Value>& args, Func
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
throwTypeError(args.GetIsolate());
return;
@@ -598,7 +597,7 @@ static void uniformHelperi(const v8::FunctionCallbackInfo<v8::Value>& args, Func
if (V8Int32Array::HasInstance(args[1], args.GetIsolate(), worldType(args.GetIsolate()))) {
Int32Array* array = V8Int32Array::toNative(args[1]->ToObject());
- ASSERT(array != NULL);
+ ASSERT(array);
switch (functionToCall) {
case kUniform1v: context->uniform1iv(location, array); break;
case kUniform2v: context->uniform2iv(location, array); break;
@@ -613,8 +612,7 @@ static void uniformHelperi(const v8::FunctionCallbackInfo<v8::Value>& args, Func
throwTypeError(args.GetIsolate());
return;
}
- v8::Handle<v8::Array> array =
- v8::Local<v8::Array>::Cast(args[1]);
+ v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]);
uint32_t len = array->Length();
int* data = jsArrayToIntArray(array, len);
if (!data) {
@@ -632,42 +630,42 @@ static void uniformHelperi(const v8::FunctionCallbackInfo<v8::Value>& args, Func
fastFree(data);
}
-void V8WebGLRenderingContext::uniform1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kUniform1v);
}
-void V8WebGLRenderingContext::uniform1ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform1ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
uniformHelperi(args, kUniform1v);
}
-void V8WebGLRenderingContext::uniform2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kUniform2v);
}
-void V8WebGLRenderingContext::uniform2ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform2ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
uniformHelperi(args, kUniform2v);
}
-void V8WebGLRenderingContext::uniform3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kUniform3v);
}
-void V8WebGLRenderingContext::uniform3ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform3ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
uniformHelperi(args, kUniform3v);
}
-void V8WebGLRenderingContext::uniform4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kUniform4v);
}
-void V8WebGLRenderingContext::uniform4ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniform4ivMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
uniformHelperi(args, kUniform4v);
}
@@ -688,7 +686,7 @@ static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args,
return;
}
- WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
+ WebGLRenderingContextBase* context = V8WebGLRenderingContextBase::toNative(args.Holder());
if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) {
throwTypeError(args.GetIsolate());
@@ -700,7 +698,7 @@ static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args,
bool transpose = args[1]->BooleanValue();
if (V8Float32Array::HasInstance(args[2], args.GetIsolate(), worldType(args.GetIsolate()))) {
Float32Array* array = V8Float32Array::toNative(args[2]->ToObject());
- ASSERT(array != NULL);
+ ASSERT(array);
switch (matrixSize) {
case 2: context->uniformMatrix2fv(location, transpose, array); break;
case 3: context->uniformMatrix3fv(location, transpose, array); break;
@@ -714,8 +712,7 @@ static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args,
throwTypeError(args.GetIsolate());
return;
}
- v8::Handle<v8::Array> array =
- v8::Local<v8::Array>::Cast(args[2]);
+ v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[2]);
uint32_t len = array->Length();
float* data = jsArrayToFloatArray(array, len);
if (!data) {
@@ -732,37 +729,37 @@ static void uniformMatrixHelper(const v8::FunctionCallbackInfo<v8::Value>& args,
fastFree(data);
}
-void V8WebGLRenderingContext::uniformMatrix2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniformMatrix2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
uniformMatrixHelper(args, 2);
}
-void V8WebGLRenderingContext::uniformMatrix3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniformMatrix3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
uniformMatrixHelper(args, 3);
}
-void V8WebGLRenderingContext::uniformMatrix4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::uniformMatrix4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
uniformMatrixHelper(args, 4);
}
-void V8WebGLRenderingContext::vertexAttrib1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::vertexAttrib1fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kVertexAttrib1v);
}
-void V8WebGLRenderingContext::vertexAttrib2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::vertexAttrib2fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kVertexAttrib2v);
}
-void V8WebGLRenderingContext::vertexAttrib3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::vertexAttrib3fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kVertexAttrib3v);
}
-void V8WebGLRenderingContext::vertexAttrib4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
+void V8WebGLRenderingContextBase::vertexAttrib4fvMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
vertexAttribAndUniformHelperf(args, kVertexAttrib4v);
}

Powered by Google App Engine
This is Rietveld 408576698