Bug 40746

Summary: WebGLShader now keeps track of its shader type
Product: WebKit Reporter: Paul Sawaya <psawaya>
Component: WebGLAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Enhancement CC: adele, cmarrin, kbr, zmo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
WebGLShader now keeps track of its shader type
cmarrin: review-
Added accessor, and made other code style changes as requested sam: review-

Description Paul Sawaya 2010-06-16 16:43:47 PDT
Created attachment 58945 [details]
WebGLShader now keeps track of its shader type

WebGLShader needs to keep track of which type of shader it is (vertex, or fragment) to prepare for future enhancements to WebGL.
Comment 1 Kenneth Russell 2010-06-16 16:57:14 PDT
Comment on attachment 58945 [details]
WebGLShader now keeps track of its shader type

WebCore/html/canvas/WebGLShader.h:45
 +          GraphicsContext3D::WebGLEnumType shaderType;
To conform to the WebKit style guide this should be "m_shaderType".


WebCore/html/canvas/WebGLShader.cpp:43
 +      shaderType = type;
This can be initialized in the initializer list: e.g.

  : CanvasObject(ctx)
  , m_shaderType(type)
Comment 2 Chris Marrin 2010-06-16 17:14:55 PDT
Comment on attachment 58945 [details]
WebGLShader now keeps track of its shader type

> Index: WebCore/html/canvas/WebGLShader.cpp
> ===================================================================
> --- WebCore/html/canvas/WebGLShader.cpp	(revision 60639)
> +++ WebCore/html/canvas/WebGLShader.cpp	(working copy)
> @@ -40,6 +40,8 @@ PassRefPtr<WebGLShader> WebGLShader::cre
>  WebGLShader::WebGLShader(WebGLRenderingContext* ctx, GraphicsContext3D::WebGLEnumType type)
>      : CanvasObject(ctx)
>  {
> +    shaderType = type;
> +
>      setObject(context()->graphicsContext3D()->createShader(type));
>  }
>  
> Index: WebCore/html/canvas/WebGLShader.h
> ===================================================================
> --- WebCore/html/canvas/WebGLShader.h	(revision 60639)
> +++ WebCore/html/canvas/WebGLShader.h	(working copy)
> @@ -41,6 +41,8 @@ namespace WebCore {
>  
>      private:
>          WebGLShader(WebGLRenderingContext*, GraphicsContext3D::WebGLEnumType);
> +            
> +        GraphicsContext3D::WebGLEnumType shaderType;
>  
>          virtual void _deleteObject(Platform3DObject);
>  

WebCore/html/canvas/WebGLShader.cpp:43
 +      shaderType = type;
This can be initialized in the constructor, as in:

    : CanvasObject(ctx)
    , m_shaderType(type)


WebCore/html/canvas/WebGLShader.h:45
 +          GraphicsContext3D::WebGLEnumType shaderType;

The convention is to name this m_shaderType


WebCore/html/canvas/WebGLShader.h:46
 +  

You should add an accessor:

    GraphicsContext3D::WebGLEnumType shaderType () const { return m_shaderType; }
Comment 3 Paul Sawaya 2010-06-17 11:03:10 PDT
Created attachment 59015 [details]
Added accessor, and made other code style changes as requested
Comment 4 Sam Weinig 2010-06-17 22:02:14 PDT
Comment on attachment 59015 [details]
Added accessor, and made other code style changes as requested

>  WebGLShader::WebGLShader(WebGLRenderingContext* ctx, GraphicsContext3D::WebGLEnumType type)
> -    : CanvasObject(ctx)
> +    : CanvasObject(ctx), m_shaderType(type)

The ", m_shaderType(type)" should be on its own line.


This change is also missing a ChangeLog.  Please read http://webkit.org/coding/contributing.html for more information on how to do this.
Comment 5 Zhenyao Mo 2010-07-03 16:19:05 PDT
Sorry I didn't see this bug before.  The feature is actually implemented in another bug: https://bugs.webkit.org/show_bug.cgi?id=41380.

*** This bug has been marked as a duplicate of bug 41380 ***
Comment 6 Daniel Bates 2010-07-23 22:18:14 PDT
Comment on attachment 59015 [details]
Added accessor, and made other code style changes as requested

Clearing commit-queue flag to get this out of the commit-queue.