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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContext.cpp

Issue 127163003: Completely removed the Extensions3D class (Take 2) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "core/html/canvas/WebGLUniformLocation.h" 67 #include "core/html/canvas/WebGLUniformLocation.h"
68 #include "core/inspector/InspectorInstrumentation.h" 68 #include "core/inspector/InspectorInstrumentation.h"
69 #include "core/loader/FrameLoader.h" 69 #include "core/loader/FrameLoader.h"
70 #include "core/loader/FrameLoaderClient.h" 70 #include "core/loader/FrameLoaderClient.h"
71 #include "core/frame/Frame.h" 71 #include "core/frame/Frame.h"
72 #include "core/frame/Settings.h" 72 #include "core/frame/Settings.h"
73 #include "core/rendering/RenderBox.h" 73 #include "core/rendering/RenderBox.h"
74 #include "platform/CheckedInt.h" 74 #include "platform/CheckedInt.h"
75 #include "platform/NotImplemented.h" 75 #include "platform/NotImplemented.h"
76 #include "platform/geometry/IntSize.h" 76 #include "platform/geometry/IntSize.h"
77 #include "platform/graphics/Extensions3D.h"
78 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 77 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
79 #include "platform/graphics/gpu/DrawingBuffer.h" 78 #include "platform/graphics/gpu/DrawingBuffer.h"
80 #include "public/platform/Platform.h" 79 #include "public/platform/Platform.h"
81 80
82 #include "wtf/PassOwnPtr.h" 81 #include "wtf/PassOwnPtr.h"
83 #include "wtf/Uint32Array.h" 82 #include "wtf/Uint32Array.h"
84 #include "wtf/text/StringBuilder.h" 83 #include "wtf/text/StringBuilder.h"
85 84
86 namespace WebCore { 85 namespace WebCore {
87 86
(...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL: 2429 case GC3D_UNPACK_PREMULTIPLY_ALPHA_WEBGL:
2431 return WebGLGetInfo(m_unpackPremultiplyAlpha); 2430 return WebGLGetInfo(m_unpackPremultiplyAlpha);
2432 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL: 2431 case GC3D_UNPACK_COLORSPACE_CONVERSION_WEBGL:
2433 return WebGLGetInfo(m_unpackColorspaceConversion); 2432 return WebGLGetInfo(m_unpackColorspaceConversion);
2434 case GL_VENDOR: 2433 case GL_VENDOR:
2435 return WebGLGetInfo(String("WebKit")); 2434 return WebGLGetInfo(String("WebKit"));
2436 case GL_VERSION: 2435 case GL_VERSION:
2437 return WebGLGetInfo("WebGL 1.0 (" + m_contextSupport->getString(GL_VERSI ON) + ")"); 2436 return WebGLGetInfo("WebGL 1.0 (" + m_contextSupport->getString(GL_VERSI ON) + ")");
2438 case GL_VIEWPORT: 2437 case GL_VIEWPORT:
2439 return getWebGLIntArrayParameter(pname); 2438 return getWebGLIntArrayParameter(pname);
2440 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives 2439 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives
2441 if (m_oesStandardDerivatives) 2440 if (m_oesStandardDerivatives)
2442 return getUnsignedIntParameter(Extensions3D::FRAGMENT_SHADER_DERIVAT IVE_HINT_OES); 2441 return getUnsignedIntParameter(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OE S);
2443 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_standard_derivatives not enabled"); 2442 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_standard_derivatives not enabled");
2444 return WebGLGetInfo(); 2443 return WebGLGetInfo();
2445 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL: 2444 case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
2446 if (m_webglDebugRendererInfo) 2445 if (m_webglDebugRendererInfo)
2447 return WebGLGetInfo(m_contextSupport->getString(GL_RENDERER)); 2446 return WebGLGetInfo(m_contextSupport->getString(GL_RENDERER));
2448 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); 2447 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2449 return WebGLGetInfo(); 2448 return WebGLGetInfo();
2450 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: 2449 case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL:
2451 if (m_webglDebugRendererInfo) 2450 if (m_webglDebugRendererInfo)
2452 return WebGLGetInfo(m_contextSupport->getString(GL_VENDOR)); 2451 return WebGLGetInfo(m_contextSupport->getString(GL_VENDOR));
2453 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled"); 2452 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_debug_renderer_info not enabled");
2454 return WebGLGetInfo(); 2453 return WebGLGetInfo();
2455 case Extensions3D::VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object 2454 case GL_VERTEX_ARRAY_BINDING_OES: // OES_vertex_array_object
2456 if (m_oesVertexArrayObject) { 2455 if (m_oesVertexArrayObject) {
2457 if (!m_boundVertexArrayObject->isDefaultObject()) 2456 if (!m_boundVertexArrayObject->isDefaultObject())
2458 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun dVertexArrayObject)); 2457 return WebGLGetInfo(PassRefPtr<WebGLVertexArrayObjectOES>(m_boun dVertexArrayObject));
2459 return WebGLGetInfo(); 2458 return WebGLGetInfo();
2460 } 2459 }
2461 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled"); 2460 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, OES_vertex_array_object not enabled");
2462 return WebGLGetInfo(); 2461 return WebGLGetInfo();
2463 case Extensions3D::MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_ani sotropic 2462 case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic
2464 if (m_extTextureFilterAnisotropic) 2463 if (m_extTextureFilterAnisotropic)
2465 return getUnsignedIntParameter(Extensions3D::MAX_TEXTURE_MAX_ANISOTR OPY_EXT); 2464 return getUnsignedIntParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
2466 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled"); 2465 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, EXT_texture_filter_anisotropic not enabled");
2467 return WebGLGetInfo(); 2466 return WebGLGetInfo();
2468 case Extensions3D::MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN 2467 case GL_MAX_COLOR_ATTACHMENTS_EXT: // EXT_draw_buffers BEGIN
2469 if (m_webglDrawBuffers) 2468 if (m_webglDrawBuffers)
2470 return WebGLGetInfo(maxColorAttachments()); 2469 return WebGLGetInfo(maxColorAttachments());
2471 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled"); 2470 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled");
2472 return WebGLGetInfo(); 2471 return WebGLGetInfo();
2473 case Extensions3D::MAX_DRAW_BUFFERS_EXT: 2472 case GL_MAX_DRAW_BUFFERS_EXT:
2474 if (m_webglDrawBuffers) 2473 if (m_webglDrawBuffers)
2475 return WebGLGetInfo(maxDrawBuffers()); 2474 return WebGLGetInfo(maxDrawBuffers());
2476 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled"); 2475 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me, WEBGL_draw_buffers not enabled");
2477 return WebGLGetInfo(); 2476 return WebGLGetInfo();
2478 default: 2477 default:
2479 if (m_webglDrawBuffers 2478 if (m_webglDrawBuffers
2480 && pname >= Extensions3D::DRAW_BUFFER0_EXT 2479 && pname >= GL_DRAW_BUFFER0_EXT
2481 && pname < static_cast<GLenum>(Extensions3D::DRAW_BUFFER0_EXT + maxD rawBuffers())) { 2480 && pname < static_cast<GLenum>(GL_DRAW_BUFFER0_EXT + maxDrawBuffers( ))) {
2482 GLint value = GL_NONE; 2481 GLint value = GL_NONE;
2483 if (m_framebufferBinding) 2482 if (m_framebufferBinding)
2484 value = m_framebufferBinding->getDrawBuffer(pname); 2483 value = m_framebufferBinding->getDrawBuffer(pname);
2485 else // emulated backbuffer 2484 else // emulated backbuffer
2486 value = m_backDrawBuffer; 2485 value = m_backDrawBuffer;
2487 return WebGLGetInfo(value); 2486 return WebGLGetInfo(value);
2488 } 2487 }
2489 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me"); 2488 synthesizeGLError(GL_INVALID_ENUM, "getParameter", "invalid parameter na me");
2490 return WebGLGetInfo(); 2489 return WebGLGetInfo();
2491 } 2490 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 if (!tex) 2663 if (!tex)
2665 return WebGLGetInfo(); 2664 return WebGLGetInfo();
2666 GLint value = 0; 2665 GLint value = 0;
2667 switch (pname) { 2666 switch (pname) {
2668 case GL_TEXTURE_MAG_FILTER: 2667 case GL_TEXTURE_MAG_FILTER:
2669 case GL_TEXTURE_MIN_FILTER: 2668 case GL_TEXTURE_MIN_FILTER:
2670 case GL_TEXTURE_WRAP_S: 2669 case GL_TEXTURE_WRAP_S:
2671 case GL_TEXTURE_WRAP_T: 2670 case GL_TEXTURE_WRAP_T:
2672 m_context->getTexParameteriv(target, pname, &value); 2671 m_context->getTexParameteriv(target, pname, &value);
2673 return WebGLGetInfo(static_cast<unsigned>(value)); 2672 return WebGLGetInfo(static_cast<unsigned>(value));
2674 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic 2673 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic
2675 if (m_extTextureFilterAnisotropic) { 2674 if (m_extTextureFilterAnisotropic) {
2676 m_context->getTexParameteriv(target, pname, &value); 2675 m_context->getTexParameteriv(target, pname, &value);
2677 return WebGLGetInfo(static_cast<unsigned>(value)); 2676 return WebGLGetInfo(static_cast<unsigned>(value));
2678 } 2677 }
2679 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name, EXT_texture_filter_anisotropic not enabled"); 2678 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name, EXT_texture_filter_anisotropic not enabled");
2680 return WebGLGetInfo(); 2679 return WebGLGetInfo();
2681 default: 2680 default:
2682 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name"); 2681 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter name");
2683 return WebGLGetInfo(); 2682 return WebGLGetInfo();
2684 } 2683 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2850 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GLuint index, GLenum pname) 2849 WebGLGetInfo WebGLRenderingContext::getVertexAttrib(GLuint index, GLenum pname)
2851 { 2850 {
2852 if (isContextLost()) 2851 if (isContextLost())
2853 return WebGLGetInfo(); 2852 return WebGLGetInfo();
2854 if (index >= m_maxVertexAttribs) { 2853 if (index >= m_maxVertexAttribs) {
2855 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran ge"); 2854 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran ge");
2856 return WebGLGetInfo(); 2855 return WebGLGetInfo();
2857 } 2856 }
2858 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index); 2857 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArr ayObject->getVertexAttribState(index);
2859 2858
2860 if (m_angleInstancedArrays && pname == Extensions3D::VERTEX_ATTRIB_ARRAY_DIV ISOR_ANGLE) 2859 if (m_angleInstancedArrays && pname == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE)
2861 return WebGLGetInfo(state.divisor); 2860 return WebGLGetInfo(state.divisor);
2862 2861
2863 switch (pname) { 2862 switch (pname) {
2864 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 2863 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
2865 if (!state.bufferBinding || !state.bufferBinding->object()) 2864 if (!state.bufferBinding || !state.bufferBinding->object())
2866 return WebGLGetInfo(); 2865 return WebGLGetInfo();
2867 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding)); 2866 return WebGLGetInfo(PassRefPtr<WebGLBuffer>(state.bufferBinding));
2868 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: 2867 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
2869 return WebGLGetInfo(state.enabled); 2868 return WebGLGetInfo(state.enabled);
2870 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: 2869 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
(...skipping 26 matching lines...) Expand all
2897 2896
2898 void WebGLRenderingContext::hint(GLenum target, GLenum mode) 2897 void WebGLRenderingContext::hint(GLenum target, GLenum mode)
2899 { 2898 {
2900 if (isContextLost()) 2899 if (isContextLost())
2901 return; 2900 return;
2902 bool isValid = false; 2901 bool isValid = false;
2903 switch (target) { 2902 switch (target) {
2904 case GL_GENERATE_MIPMAP_HINT: 2903 case GL_GENERATE_MIPMAP_HINT:
2905 isValid = true; 2904 isValid = true;
2906 break; 2905 break;
2907 case Extensions3D::FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_deri vatives 2906 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives
2908 if (m_oesStandardDerivatives) 2907 if (m_oesStandardDerivatives)
2909 isValid = true; 2908 isValid = true;
2910 break; 2909 break;
2911 } 2910 }
2912 if (!isValid) { 2911 if (!isValid) {
2913 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target"); 2912 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target");
2914 return; 2913 return;
2915 } 2914 }
2916 m_context->hint(target, mode); 2915 m_context->hint(target, mode);
2917 } 2916 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 case GL_RGB5_A1: 3154 case GL_RGB5_A1:
3156 case GL_RGB565: 3155 case GL_RGB565:
3157 case GL_STENCIL_INDEX8: 3156 case GL_STENCIL_INDEX8:
3158 m_context->renderbufferStorage(target, internalformat, width, height); 3157 m_context->renderbufferStorage(target, internalformat, width, height);
3159 m_renderbufferBinding->setInternalFormat(internalformat); 3158 m_renderbufferBinding->setInternalFormat(internalformat);
3160 m_renderbufferBinding->setSize(width, height); 3159 m_renderbufferBinding->setSize(width, height);
3161 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_contextSupport.get( )); 3160 m_renderbufferBinding->deleteEmulatedStencilBuffer(m_contextSupport.get( ));
3162 break; 3161 break;
3163 case GL_DEPTH_STENCIL_OES: 3162 case GL_DEPTH_STENCIL_OES:
3164 if (isDepthStencilSupported()) { 3163 if (isDepthStencilSupported()) {
3165 m_context->renderbufferStorage(target, Extensions3D::DEPTH24_STENCIL 8, width, height); 3164 m_context->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, widt h, height);
3166 } else { 3165 } else {
3167 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(target, m_renderbufferBinding.get()); 3166 WebGLRenderbuffer* emulatedStencilBuffer = ensureEmulatedStencilBuff er(target, m_renderbufferBinding.get());
3168 if (!emulatedStencilBuffer) { 3167 if (!emulatedStencilBuffer) {
3169 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out of memory"); 3168 synthesizeGLError(GL_OUT_OF_MEMORY, "renderbufferStorage", "out of memory");
3170 return; 3169 return;
3171 } 3170 }
3172 m_context->renderbufferStorage(target, GL_DEPTH_COMPONENT16, width, height); 3171 m_context->renderbufferStorage(target, GL_DEPTH_COMPONENT16, width, height);
3173 m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuff er)); 3172 m_context->bindRenderbuffer(target, objectOrZero(emulatedStencilBuff er));
3174 m_context->renderbufferStorage(target, GL_STENCIL_INDEX8, width, hei ght); 3173 m_context->renderbufferStorage(target, GL_STENCIL_INDEX8, width, hei ght);
3175 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng.get())); 3174 m_context->bindRenderbuffer(target, objectOrZero(m_renderbufferBindi ng.get()));
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 case GL_TEXTURE_MAG_FILTER: 3551 case GL_TEXTURE_MAG_FILTER:
3553 break; 3552 break;
3554 case GL_TEXTURE_WRAP_S: 3553 case GL_TEXTURE_WRAP_S:
3555 case GL_TEXTURE_WRAP_T: 3554 case GL_TEXTURE_WRAP_T:
3556 if ((isFloat && paramf != GL_CLAMP_TO_EDGE && paramf != GL_MIRRORED_REPE AT && paramf != GL_REPEAT) 3555 if ((isFloat && paramf != GL_CLAMP_TO_EDGE && paramf != GL_MIRRORED_REPE AT && paramf != GL_REPEAT)
3557 || (!isFloat && parami != GL_CLAMP_TO_EDGE && parami != GL_MIRRORED_ REPEAT && parami != GL_REPEAT)) { 3556 || (!isFloat && parami != GL_CLAMP_TO_EDGE && parami != GL_MIRRORED_ REPEAT && parami != GL_REPEAT)) {
3558 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete r"); 3557 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete r");
3559 return; 3558 return;
3560 } 3559 }
3561 break; 3560 break;
3562 case Extensions3D::TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotr opic 3561 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic
3563 if (!m_extTextureFilterAnisotropic) { 3562 if (!m_extTextureFilterAnisotropic) {
3564 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete r, EXT_texture_filter_anisotropic not enabled"); 3563 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid paramete r, EXT_texture_filter_anisotropic not enabled");
3565 return; 3564 return;
3566 } 3565 }
3567 break; 3566 break;
3568 default: 3567 default:
3569 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid parameter na me"); 3568 synthesizeGLError(GL_INVALID_ENUM, "texParameter", "invalid parameter na me");
3570 return; 3569 return;
3571 } 3570 }
3572 if (isFloat) { 3571 if (isFloat) {
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4819 return false; 4818 return false;
4820 } 4819 }
4821 if (width < 0 || height < 0) { 4820 if (width < 0 || height < 0) {
4822 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height < 0") ; 4821 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height < 0") ;
4823 return false; 4822 return false;
4824 } 4823 }
4825 4824
4826 unsigned bytesRequired = 0; 4825 unsigned bytesRequired = 0;
4827 4826
4828 switch (format) { 4827 switch (format) {
4829 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: 4828 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
4830 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: 4829 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
4831 { 4830 {
4832 const int kBlockWidth = 4; 4831 const int kBlockWidth = 4;
4833 const int kBlockHeight = 4; 4832 const int kBlockHeight = 4;
4834 const int kBlockSize = 8; 4833 const int kBlockSize = 8;
4835 int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth; 4834 int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
4836 int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight; 4835 int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
4837 int numBlocks = numBlocksAcross * numBlocksDown; 4836 int numBlocks = numBlocksAcross * numBlocksDown;
4838 bytesRequired = numBlocks * kBlockSize; 4837 bytesRequired = numBlocks * kBlockSize;
4839 } 4838 }
4840 break; 4839 break;
4841 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: 4840 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
4842 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: 4841 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
4843 { 4842 {
4844 const int kBlockWidth = 4; 4843 const int kBlockWidth = 4;
4845 const int kBlockHeight = 4; 4844 const int kBlockHeight = 4;
4846 const int kBlockSize = 16; 4845 const int kBlockSize = 16;
4847 int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth; 4846 int numBlocksAcross = (width + kBlockWidth - 1) / kBlockWidth;
4848 int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight; 4847 int numBlocksDown = (height + kBlockHeight - 1) / kBlockHeight;
4849 int numBlocks = numBlocksAcross * numBlocksDown; 4848 int numBlocks = numBlocksAcross * numBlocksDown;
4850 bytesRequired = numBlocks * kBlockSize; 4849 bytesRequired = numBlocks * kBlockSize;
4851 } 4850 }
4852 break; 4851 break;
4853 case Extensions3D::COMPRESSED_ATC_RGB_AMD: 4852 case GC3D_COMPRESSED_ATC_RGB_AMD:
4854 { 4853 {
4855 bytesRequired = floor(static_cast<double>((width + 3) / 4)) * floor( static_cast<double>((height + 3) / 4)) * 8; 4854 bytesRequired = floor(static_cast<double>((width + 3) / 4)) * floor( static_cast<double>((height + 3) / 4)) * 8;
4856 } 4855 }
4857 break; 4856 break;
4858 case Extensions3D::COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD: 4857 case GC3D_COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD:
4859 case Extensions3D::COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD: 4858 case GC3D_COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
4860 { 4859 {
4861 bytesRequired = floor(static_cast<double>((width + 3) / 4)) * floor( static_cast<double>((height + 3) / 4)) * 16; 4860 bytesRequired = floor(static_cast<double>((width + 3) / 4)) * floor( static_cast<double>((height + 3) / 4)) * 16;
4862 } 4861 }
4863 break; 4862 break;
4864 case Extensions3D::COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 4863 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
4865 case Extensions3D::COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 4864 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
4866 { 4865 {
4867 bytesRequired = max(width, 8) * max(height, 8) / 2; 4866 bytesRequired = max(width, 8) * max(height, 8) / 2;
4868 } 4867 }
4869 break; 4868 break;
4870 case Extensions3D::COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 4869 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
4871 case Extensions3D::COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 4870 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
4872 { 4871 {
4873 bytesRequired = max(width, 8) * max(height, 8) / 4; 4872 bytesRequired = max(width, 8) * max(height, 8) / 4;
4874 } 4873 }
4875 break; 4874 break;
4876 default: 4875 default:
4877 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format"); 4876 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format");
4878 return false; 4877 return false;
4879 } 4878 }
4880 4879
4881 if (pixels->byteLength() != bytesRequired) { 4880 if (pixels->byteLength() != bytesRequired) {
4882 synthesizeGLError(GL_INVALID_VALUE, functionName, "length of ArrayBuffer View is not correct for dimensions"); 4881 synthesizeGLError(GL_INVALID_VALUE, functionName, "length of ArrayBuffer View is not correct for dimensions");
4883 return false; 4882 return false;
4884 } 4883 }
4885 4884
4886 return true; 4885 return true;
4887 } 4886 }
4888 4887
4889 bool WebGLRenderingContext::validateCompressedTexDimensions(const char* function Name, TexFuncValidationFunctionType functionType, GLenum target, GLint level, GL sizei width, GLsizei height, GLenum format) 4888 bool WebGLRenderingContext::validateCompressedTexDimensions(const char* function Name, TexFuncValidationFunctionType functionType, GLenum target, GLint level, GL sizei width, GLsizei height, GLenum format)
4890 { 4889 {
4891 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) 4890 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height))
4892 return false; 4891 return false;
4893 4892
4894 switch (format) { 4893 switch (format) {
4895 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: 4894 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
4896 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: 4895 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
4897 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: 4896 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
4898 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { 4897 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: {
4899 const int kBlockWidth = 4; 4898 const int kBlockWidth = 4;
4900 const int kBlockHeight = 4; 4899 const int kBlockHeight = 4;
4901 bool widthValid = (level && width == 1) || (level && width == 2) || !(wi dth % kBlockWidth); 4900 bool widthValid = (level && width == 1) || (level && width == 2) || !(wi dth % kBlockWidth);
4902 bool heightValid = (level && height == 1) || (level && height == 2) || ! (height % kBlockHeight); 4901 bool heightValid = (level && height == 1) || (level && height == 2) || ! (height % kBlockHeight);
4903 if (!widthValid || !heightValid) { 4902 if (!widthValid || !heightValid) {
4904 synthesizeGLError(GL_INVALID_OPERATION, functionName, "width or heig ht invalid for level"); 4903 synthesizeGLError(GL_INVALID_OPERATION, functionName, "width or heig ht invalid for level");
4905 return false; 4904 return false;
4906 } 4905 }
4907 return true; 4906 return true;
4908 } 4907 }
4909 default: 4908 default:
4910 return false; 4909 return false;
4911 } 4910 }
4912 } 4911 }
4913 4912
4914 bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* funct ionName, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width , GLsizei height, GLenum format, WebGLTexture* tex) 4913 bool WebGLRenderingContext::validateCompressedTexSubDimensions(const char* funct ionName, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width , GLsizei height, GLenum format, WebGLTexture* tex)
4915 { 4914 {
4916 if (xoffset < 0 || yoffset < 0) { 4915 if (xoffset < 0 || yoffset < 0) {
4917 synthesizeGLError(GL_INVALID_VALUE, functionName, "xoffset or yoffset < 0"); 4916 synthesizeGLError(GL_INVALID_VALUE, functionName, "xoffset or yoffset < 0");
4918 return false; 4917 return false;
4919 } 4918 }
4920 4919
4921 switch (format) { 4920 switch (format) {
4922 case Extensions3D::COMPRESSED_RGB_S3TC_DXT1_EXT: 4921 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
4923 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT1_EXT: 4922 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
4924 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT3_EXT: 4923 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
4925 case Extensions3D::COMPRESSED_RGBA_S3TC_DXT5_EXT: { 4924 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: {
4926 const int kBlockWidth = 4; 4925 const int kBlockWidth = 4;
4927 const int kBlockHeight = 4; 4926 const int kBlockHeight = 4;
4928 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { 4927 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) {
4929 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset not multiple of 4"); 4928 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset not multiple of 4");
4930 return false; 4929 return false;
4931 } 4930 }
4932 if (width - xoffset > tex->getWidth(target, level) 4931 if (width - xoffset > tex->getWidth(target, level)
4933 || height - yoffset > tex->getHeight(target, level)) { 4932 || height - yoffset > tex->getHeight(target, level)) {
4934 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions ou t of range"); 4933 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions ou t of range");
4935 return false; 4934 return false;
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
5571 { 5570 {
5572 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), 5571 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]),
5573 clamp(canvas()->height(), 1, m_maxViewportDims[1])); 5572 clamp(canvas()->height(), 1, m_maxViewportDims[1]));
5574 } 5573 }
5575 5574
5576 GLint WebGLRenderingContext::maxDrawBuffers() 5575 GLint WebGLRenderingContext::maxDrawBuffers()
5577 { 5576 {
5578 if (isContextLost() || !m_webglDrawBuffers) 5577 if (isContextLost() || !m_webglDrawBuffers)
5579 return 0; 5578 return 0;
5580 if (!m_maxDrawBuffers) 5579 if (!m_maxDrawBuffers)
5581 m_context->getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuf fers); 5580 m_context->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuffers);
5582 if (!m_maxColorAttachments) 5581 if (!m_maxColorAttachments)
5583 m_context->getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &m_maxCo lorAttachments); 5582 m_context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachme nts);
5584 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. 5583 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS.
5585 return std::min(m_maxDrawBuffers, m_maxColorAttachments); 5584 return std::min(m_maxDrawBuffers, m_maxColorAttachments);
5586 } 5585 }
5587 5586
5588 GLint WebGLRenderingContext::maxColorAttachments() 5587 GLint WebGLRenderingContext::maxColorAttachments()
5589 { 5588 {
5590 if (isContextLost() || !m_webglDrawBuffers) 5589 if (isContextLost() || !m_webglDrawBuffers)
5591 return 0; 5590 return 0;
5592 if (!m_maxColorAttachments) 5591 if (!m_maxColorAttachments)
5593 m_context->getIntegerv(Extensions3D::MAX_COLOR_ATTACHMENTS_EXT, &m_maxCo lorAttachments); 5592 m_context->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttachme nts);
5594 return m_maxColorAttachments; 5593 return m_maxColorAttachments;
5595 } 5594 }
5596 5595
5597 void WebGLRenderingContext::setBackDrawBuffer(GLenum buf) 5596 void WebGLRenderingContext::setBackDrawBuffer(GLenum buf)
5598 { 5597 {
5599 m_backDrawBuffer = buf; 5598 m_backDrawBuffer = buf;
5600 } 5599 }
5601 5600
5602 void WebGLRenderingContext::restoreCurrentFramebuffer() 5601 void WebGLRenderingContext::restoreCurrentFramebuffer()
5603 { 5602 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
5638 if (m_textureUnits[i].m_texture2DBinding 5637 if (m_textureUnits[i].m_texture2DBinding
5639 || m_textureUnits[i].m_textureCubeMapBinding) { 5638 || m_textureUnits[i].m_textureCubeMapBinding) {
5640 m_onePlusMaxNonDefaultTextureUnit = i + 1; 5639 m_onePlusMaxNonDefaultTextureUnit = i + 1;
5641 return; 5640 return;
5642 } 5641 }
5643 } 5642 }
5644 m_onePlusMaxNonDefaultTextureUnit = 0; 5643 m_onePlusMaxNonDefaultTextureUnit = 0;
5645 } 5644 }
5646 5645
5647 } // namespace WebCore 5646 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLFramebuffer.cpp ('k') | Source/core/html/canvas/WebGLVertexArrayObjectOES.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698