Changeset 49420 in webkit
- Timestamp:
- Oct 10, 2009 2:16:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 10 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r49414 r49420 1 2009-10-10 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Eric Carlson. 4 5 Implement getActiveAttrib and getActiveUniform 6 https://bugs.webkit.org/show_bug.cgi?id=30276 7 8 Adds test for getActiveAttrib and getActiveUniform. Additionally 9 adds a basic shader pair, and a utility library to do the more 10 mechanical work needed to set up a WebGL context for testing. 11 12 * fast/canvas/webgl/getActiveTest-expected.txt: Added. 13 * fast/canvas/webgl/getActiveTest.html: Added. 14 * fast/canvas/webgl/resources/fragmentShader.frag: Added. 15 * fast/canvas/webgl/resources/shader-test.js: Added. 16 (getShaderSource): 17 (create3DContext): 18 (loadStandardProgram): 19 * fast/canvas/webgl/resources/vertexShader.vert: Added. 20 * fast/canvas/webgl/script-tests/getActiveTest.js: Added. 21 1 22 2009-10-09 Ryosuke Niwa <rniwa@webkit.org> 2 23 -
trunk/WebCore/ChangeLog
r49419 r49420 1 2009-10-10 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Eric Carlson. 4 5 Implement getActiveAttrib and getActiveUniform 6 https://bugs.webkit.org/show_bug.cgi?id=30276 7 8 Implements the getActiveAttrib and getActiveUniform APIs. 9 Rather simple patch, adds CanvasActiveInfo definition and implementation 10 and adds forwarding to the GraphicsContext3D. 11 12 Test: fast/canvas/webgl/getActiveTest.html 13 14 * DerivedSources.make: 15 * WebCore.xcodeproj/project.pbxproj: 16 * html/canvas/CanvasActiveInfo.h: Added. 17 (WebCore::CanvasActiveInfo::create): 18 (WebCore::CanvasActiveInfo::name): 19 (WebCore::CanvasActiveInfo::type): 20 (WebCore::CanvasActiveInfo::size): 21 (WebCore::CanvasActiveInfo::CanvasActiveInfo): 22 * html/canvas/CanvasActiveInfo.idl: Added. 23 * html/canvas/CanvasObject.h: 24 (WebCore::CanvasObject::context): 25 Need to make the context public as it is needed to ensure we don't 26 provide a program from one context as an argument to another. 27 * html/canvas/CanvasRenderingContext3D.cpp: 28 (WebCore::CanvasRenderingContext3D::getActiveAttrib): 29 (WebCore::CanvasRenderingContext3D::getActiveUniform): 30 * html/canvas/CanvasRenderingContext3D.h: 31 * html/canvas/CanvasRenderingContext3D.idl: 32 * platform/graphics/GraphicsContext3D.h: 33 * platform/graphics/mac/GraphicsContext3DMac.cpp: 34 (WebCore::GraphicsContext3D::getActiveAttrib): 35 (WebCore::GraphicsContext3D::getActiveUniform): 36 1 37 2009-10-10 Pavel Feldman <pfeldman@chromium.org> 2 38 -
trunk/WebCore/DerivedSources.make
r49400 r49420 71 71 CSSVariablesRule \ 72 72 CSSVariablesDeclaration \ 73 CanvasActiveInfo \ 73 74 CanvasArray \ 74 75 CanvasArrayBuffer \ -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r49415 r49420 2397 2397 A7CFB3D50B7ED1180070C32D /* DragImageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */; }; 2398 2398 A7D0318E0E93540300E24ACD /* JSImageDataCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */; }; 2399 A7D20F62107F406900A80392 /* JSCanvasActiveInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D20F60107F406900A80392 /* JSCanvasActiveInfo.cpp */; }; 2400 A7D20F63107F406900A80392 /* JSCanvasActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F61107F406900A80392 /* JSCanvasActiveInfo.h */; }; 2401 A7D20F6D107F438B00A80392 /* CanvasActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F6B107F438B00A80392 /* CanvasActiveInfo.h */; }; 2399 2402 A7D27FC40E0A599F0079AD2B /* SVGFETile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D27FC30E0A599F0079AD2B /* SVGFETile.cpp */; }; 2400 2403 A7D3C5240B576B4B002CA450 /* PasteboardHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 7602 7605 A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DragImageMac.mm; sourceTree = "<group>"; }; 7603 7606 A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSImageDataCustom.cpp; sourceTree = "<group>"; }; 7607 A7D20F3B107F373800A80392 /* CanvasActiveInfo.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CanvasActiveInfo.idl; path = canvas/CanvasActiveInfo.idl; sourceTree = "<group>"; }; 7608 A7D20F60107F406900A80392 /* JSCanvasActiveInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSCanvasActiveInfo.cpp; path = /Users/oliver/builds/Debug/DerivedSources/WebCore/JSCanvasActiveInfo.cpp; sourceTree = "<absolute>"; }; 7609 A7D20F61107F406900A80392 /* JSCanvasActiveInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSCanvasActiveInfo.h; path = /Users/oliver/builds/Debug/DerivedSources/WebCore/JSCanvasActiveInfo.h; sourceTree = "<absolute>"; }; 7610 A7D20F6B107F438B00A80392 /* CanvasActiveInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasActiveInfo.h; path = canvas/CanvasActiveInfo.h; sourceTree = "<group>"; }; 7604 7611 A7D27FC30E0A599F0079AD2B /* SVGFETile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFETile.cpp; sourceTree = "<group>"; }; 7605 7612 A7D3C5230B576B4B002CA450 /* PasteboardHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PasteboardHelper.h; sourceTree = "<group>"; }; … … 10621 10628 49EECDDD10503C2400099FAB /* CanvasUnsignedShortArray.h */, 10622 10629 49EECDDE10503C2400099FAB /* CanvasUnsignedShortArray.idl */, 10630 A7D20F3B107F373800A80392 /* CanvasActiveInfo.idl */, 10631 A7D20F6B107F438B00A80392 /* CanvasActiveInfo.h */, 10623 10632 ); 10624 10633 name = canvas; … … 12714 12723 isa = PBXGroup; 12715 12724 children = ( 12725 A7D20F60107F406900A80392 /* JSCanvasActiveInfo.cpp */, 12726 A7D20F61107F406900A80392 /* JSCanvasActiveInfo.h */, 12716 12727 49EECF19105072F300099FAB /* JSCanvasArray.cpp */, 12717 12728 49EECF1A105072F300099FAB /* JSCanvasArray.h */, … … 18012 18023 97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */, 18013 18024 97DCE20210807C750057D394 /* HistoryController.h in Headers */, 18025 A7D20F63107F406900A80392 /* JSCanvasActiveInfo.h in Headers */, 18026 A7D20F6D107F438B00A80392 /* CanvasActiveInfo.h in Headers */, 18014 18027 ); 18015 18028 runOnlyForDeploymentPostprocessing = 0; … … 20140 20153 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */, 20141 20154 97DCE20110807C750057D394 /* HistoryController.cpp in Sources */, 20155 A7D20F62107F406900A80392 /* JSCanvasActiveInfo.cpp in Sources */, 20142 20156 ); 20143 20157 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/html/canvas/CanvasActiveInfo.h
r49419 r49420 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 11 11 * documentation and/or other materials provided with the distribution. 12 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER,INC. ``AS IS'' AND ANY13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER,INC. OR16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, … … 24 24 */ 25 25 26 #ifndef Canvas Object_h27 #define Canvas Object_h26 #ifndef CanvasActiveInfo_h 27 #define CanvasActiveInfo_h 28 28 29 #include "PlatformString.h" 29 30 #include <wtf/PassRefPtr.h> 30 31 #include <wtf/RefCounted.h> 31 32 32 #include "GraphicsContext3D.h"33 34 33 namespace WebCore { 35 34 36 class CanvasRenderingContext3D; 37 38 class CanvasObject : public RefCounted<CanvasObject> { 39 public: 40 virtual ~CanvasObject(); 41 42 Platform3DObject object() const { return m_object; } 43 void setObject(Platform3DObject); 44 void deleteObject(); 45 46 void detachContext() 47 { 48 deleteObject(); 49 m_context = 0; 50 } 51 52 protected: 53 CanvasObject(CanvasRenderingContext3D*); 54 virtual void _deleteObject(Platform3DObject) = 0; 55 56 CanvasRenderingContext3D* context() const { return m_context; } 57 58 private: 59 Platform3DObject m_object; 60 CanvasRenderingContext3D* m_context; 61 }; 62 63 } // namespace WebCore 35 class CanvasActiveInfo : public RefCounted<CanvasActiveInfo> { 36 public: 37 static PassRefPtr<CanvasActiveInfo> create(const String& name, unsigned type, int size) 38 { 39 return adoptRef(new CanvasActiveInfo(name, type, size)); 40 } 41 String name() const { return m_name; } 42 unsigned type() const { return m_type; } 43 int size() const { return m_size; } 64 44 65 #endif // CanvasObject_h 45 private: 46 CanvasActiveInfo(const String& name, unsigned type, int size) 47 : m_name(name) 48 , m_type(type) 49 , m_size(size) 50 { 51 ASSERT(name.length()); 52 ASSERT(type); 53 ASSERT(size); 54 } 55 String m_name; 56 unsigned m_type; 57 int m_size; 58 }; 59 60 } 61 62 #endif // CanvasActiveInfo_h -
trunk/WebCore/html/canvas/CanvasActiveInfo.idl
r49419 r49420 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 11 11 * documentation and/or other materials provided with the distribution. 12 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER,INC. ``AS IS'' AND ANY13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER,INC. OR16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, … … 24 24 */ 25 25 26 #ifndef CanvasObject_h 27 #define CanvasObject_h 26 module html { 28 27 29 #include <wtf/PassRefPtr.h> 30 #include <wtf/RefCounted.h> 28 interface [ 29 Conditional=3D_CANVAS, 30 ] CanvasActiveInfo { 31 readonly attribute int size; 32 readonly attribute unsigned int type; 33 readonly attribute DOMString name; 34 }; 31 35 32 #include "GraphicsContext3D.h" 33 34 namespace WebCore { 35 36 class CanvasRenderingContext3D; 37 38 class CanvasObject : public RefCounted<CanvasObject> { 39 public: 40 virtual ~CanvasObject(); 41 42 Platform3DObject object() const { return m_object; } 43 void setObject(Platform3DObject); 44 void deleteObject(); 45 46 void detachContext() 47 { 48 deleteObject(); 49 m_context = 0; 50 } 51 52 protected: 53 CanvasObject(CanvasRenderingContext3D*); 54 virtual void _deleteObject(Platform3DObject) = 0; 55 56 CanvasRenderingContext3D* context() const { return m_context; } 57 58 private: 59 Platform3DObject m_object; 60 CanvasRenderingContext3D* m_context; 61 }; 62 63 } // namespace WebCore 64 65 #endif // CanvasObject_h 36 } -
trunk/WebCore/html/canvas/CanvasObject.h
r47843 r49420 49 49 m_context = 0; 50 50 } 51 51 52 CanvasRenderingContext3D* context() const { return m_context; } 53 52 54 protected: 53 55 CanvasObject(CanvasRenderingContext3D*); 54 56 virtual void _deleteObject(Platform3DObject) = 0; 55 56 CanvasRenderingContext3D* context() const { return m_context; }57 57 58 58 private: -
trunk/WebCore/html/canvas/CanvasRenderingContext3D.cpp
r48325 r49420 29 29 30 30 #include "CanvasRenderingContext3D.h" 31 32 #include "CanvasActiveInfo.h" 31 33 #include "CanvasBuffer.h" 32 34 #include "CanvasFramebuffer.h" … … 478 480 } 479 481 482 PassRefPtr<CanvasActiveInfo> CanvasRenderingContext3D::getActiveAttrib(CanvasProgram* program, unsigned long index, ExceptionCode& ec) 483 { 484 ActiveInfo info; 485 if (!program || program->context() != this || !m_context.getActiveAttrib(program, index, info)) { 486 ec = INDEX_SIZE_ERR; 487 return 0; 488 } 489 return CanvasActiveInfo::create(info.name, info.type, info.size); 490 } 491 492 PassRefPtr<CanvasActiveInfo> CanvasRenderingContext3D::getActiveUniform(CanvasProgram* program, unsigned long index, ExceptionCode& ec) 493 { 494 ActiveInfo info; 495 if (!program || program->context() != this || !m_context.getActiveUniform(program, index, info)) { 496 ec = INDEX_SIZE_ERR; 497 return 0; 498 } 499 return CanvasActiveInfo::create(info.name, info.type, info.size); 500 } 501 480 502 int CanvasRenderingContext3D::getAttribLocation(CanvasProgram* program, const String& name) 481 503 { -
trunk/WebCore/html/canvas/CanvasRenderingContext3D.h
r48325 r49420 37 37 namespace WebCore { 38 38 39 class CanvasActiveInfo; 39 40 class CanvasBuffer; 40 41 class CanvasFramebuffer; … … 124 125 void frontFace(unsigned long mode); 125 126 void generateMipmap(unsigned long target); 126 127 128 PassRefPtr<CanvasActiveInfo> getActiveAttrib(CanvasProgram*, unsigned long index, ExceptionCode&); 129 PassRefPtr<CanvasActiveInfo> getActiveUniform(CanvasProgram*, unsigned long index, ExceptionCode&); 130 127 131 int getAttribLocation(CanvasProgram*, const String& name); 128 132 -
trunk/WebCore/html/canvas/CanvasRenderingContext3D.idl
r48325 r49420 531 531 532 532 // FIXME: these need to be added per the WebGL spec 533 // CanvasActiveInfo getActiveAttrib(GLuint program, GLuint index); 534 // CanvasActiveInfo getActiveUniform(GLuint program, GLuint index); 533 CanvasActiveInfo getActiveAttrib(in CanvasProgram program, in unsigned long index) 534 raises (DOMException); 535 CanvasActiveInfo getActiveUniform(in CanvasProgram program, in unsigned long index) 536 raises (DOMException); 537 535 538 // CanvasShaderArray glGetAttachedShaders(GLuint program); 536 539 -
trunk/WebCore/platform/graphics/GraphicsContext3D.h
r49132 r49420 46 46 47 47 namespace WebCore { 48 class CanvasActiveInfo; 48 49 class CanvasArray; 49 50 class CanvasBuffer; … … 62 63 class ImageData; 63 64 class WebKitCSSMatrix; 64 65 66 struct ActiveInfo { 67 String name; 68 unsigned type; 69 int size; 70 }; 71 65 72 // FIXME: ideally this would be used on all platforms. 66 73 #if PLATFORM(CHROMIUM) … … 141 148 void frontFace(unsigned long mode); 142 149 void generateMipmap(unsigned long target); 150 151 bool getActiveAttrib(CanvasProgram* program, unsigned long index, ActiveInfo&); 152 bool getActiveUniform(CanvasProgram* program, unsigned long index, ActiveInfo&); 143 153 144 154 int getAttribLocation(CanvasProgram*, const String& name); -
trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp
r48325 r49420 31 31 32 32 #include "CachedImage.h" 33 #include "CanvasActiveInfo.h" 34 #include "CanvasArray.h" 33 35 #include "CanvasBuffer.h" 34 36 #include "CanvasFramebuffer.h" 35 #include "CanvasArray.h"36 37 #include "CanvasFloatArray.h" 37 38 #include "CanvasIntArray.h" … … 441 442 ensureContext(m_contextObj); 442 443 ::glGenerateMipmapEXT(target); 444 } 445 446 bool GraphicsContext3D::getActiveAttrib(CanvasProgram* program, unsigned long index, ActiveInfo& info) 447 { 448 if (!program->object()) 449 return false; 450 ensureContext(m_contextObj); 451 GLint maxAttributeSize = 0; 452 ::glGetProgramiv(static_cast<GLuint>(program->object()), GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttributeSize); 453 GLchar name[maxAttributeSize]; // GL_ACTIVE_ATTRIBUTE_MAX_LENGTH includes null termination 454 GLsizei nameLength = 0; 455 GLint size = 0; 456 GLenum type = 0; 457 ::glGetActiveAttrib(static_cast<GLuint>(program->object()), index, maxAttributeSize, &nameLength, &size, &type, name); 458 if (!nameLength) 459 return false; 460 info.name = String(name, nameLength); 461 info.type = type; 462 info.size = size; 463 return true; 464 } 465 466 bool GraphicsContext3D::getActiveUniform(CanvasProgram* program, unsigned long index, ActiveInfo& info) 467 { 468 if (!program->object()) 469 return false; 470 ensureContext(m_contextObj); 471 GLint maxUniformSize = 0; 472 ::glGetProgramiv(static_cast<GLuint>(program->object()), GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize); 473 GLchar name[maxUniformSize]; // GL_ACTIVE_UNIFORM_MAX_LENGTH includes null termination 474 GLsizei nameLength = 0; 475 GLint size = 0; 476 GLenum type = 0; 477 ::glGetActiveUniform(static_cast<GLuint>(program->object()), index, maxUniformSize, &nameLength, &size, &type, name); 478 if (!nameLength) 479 return false; 480 info.name = String(name, nameLength); 481 info.type = type; 482 info.size = size; 483 return true; 443 484 } 444 485
Note: See TracChangeset
for help on using the changeset viewer.