Changeset 207724 in webkit


Ignore:
Timestamp:
Oct 22, 2016 7:53:36 PM (7 years ago)
Author:
Chris Dumez
Message:

WebGLRenderingContextBase.texSubImage2D() should use a union instead of overloading
https://bugs.webkit.org/show_bug.cgi?id=163859

Reviewed by Darin Adler.

WebGLRenderingContextBase.texSubImage2D() should use a union instead of overloading:

No new tests, no Web-exposed behavior change.

  • html/canvas/WebGL2RenderingContext.cpp:

(WebCore::WebGL2RenderingContext::texSubImage2D):

  • html/canvas/WebGL2RenderingContext.h:
  • html/canvas/WebGLRenderingContext.cpp:

(WebCore::WebGLRenderingContext::texSubImage2D):

  • html/canvas/WebGLRenderingContext.h:
  • html/canvas/WebGLRenderingContextBase.h:
  • html/canvas/WebGLRenderingContextBase.idl:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207723 r207724  
     12016-10-22  Chris Dumez  <cdumez@apple.com>
     2
     3        WebGLRenderingContextBase.texSubImage2D() should use a union instead of overloading
     4        https://bugs.webkit.org/show_bug.cgi?id=163859
     5
     6        Reviewed by Darin Adler.
     7
     8        WebGLRenderingContextBase.texSubImage2D() should use a union instead of overloading:
     9        - https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14
     10
     11        No new tests, no Web-exposed behavior change.
     12
     13        * html/canvas/WebGL2RenderingContext.cpp:
     14        (WebCore::WebGL2RenderingContext::texSubImage2D):
     15        * html/canvas/WebGL2RenderingContext.h:
     16        * html/canvas/WebGLRenderingContext.cpp:
     17        (WebCore::WebGLRenderingContext::texSubImage2D):
     18        * html/canvas/WebGLRenderingContext.h:
     19        * html/canvas/WebGLRenderingContextBase.h:
     20        * html/canvas/WebGLRenderingContextBase.idl:
     21
    1222016-10-22  Dan Bernstein  <mitz@apple.com>
    223
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp

    r207720 r207724  
    11201120}
    11211121
    1122 void WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels)
    1123 {
    1124     if (isContextLostOrPending() || !pixels || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, GraphicsContext3D::NONE,  pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset))
    1125         return;
    1126    
    1127     Vector<uint8_t> data;
    1128     bool needConversion = true;
    1129     // The data from ImageData is always of format RGBA8.
    1130     // No conversion is needed if destination format is RGBA and type is USIGNED_BYTE and no Flip or Premultiply operation is required.
    1131     if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha)
    1132         needConversion = false;
    1133     else {
    1134         if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
    1135             synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
    1136             return;
    1137         }
    1138     }
    1139     if (m_unpackAlignment != 1)
    1140         m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    1141    
    1142     WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true);
    1143     GC3Denum internalformat = tex->getInternalFormat(target, level);
    1144     texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), internalformat, format, type, needConversion ? data.data() : pixels->data()->data());
    1145     if (m_unpackAlignment != 1)
    1146         m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    1147 }
    1148 
    1149 ExceptionOr<void> WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement* image)
    1150 {
    1151     if (wouldTaintOrigin(image))
    1152         return Exception { SECURITY_ERR };
    1153     if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image))
     1122ExceptionOr<void> WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Optional<TexImageSource>&& source)
     1123{
     1124    if (!source) {
     1125        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "source is null");
    11541126        return { };
    1155 
    1156     RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
    1157     if (!imageForRender)
     1127    }
     1128
     1129    auto visitor = WTF::makeVisitor([&](const RefPtr<ImageData>& pixels) -> ExceptionOr<void> {
     1130        if (isContextLostOrPending() || !pixels || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, GraphicsContext3D::NONE,  pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset))
     1131            return { };
     1132
     1133        Vector<uint8_t> data;
     1134        bool needConversion = true;
     1135        // The data from ImageData is always of format RGBA8.
     1136        // No conversion is needed if destination format is RGBA and type is USIGNED_BYTE and no Flip or Premultiply operation is required.
     1137        if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha)
     1138            needConversion = false;
     1139        else {
     1140            if (!m_context->extractImageData(pixels.get(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
     1141                synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
     1142                return { };
     1143            }
     1144        }
     1145        if (m_unpackAlignment != 1)
     1146            m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
     1147
     1148        WebGLTexture* tex = validateTextureBinding("texSubImage2D", target, true);
     1149        GC3Denum internalformat = tex->getInternalFormat(target, level);
     1150        texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), internalformat, format, type, needConversion ? data.data() : pixels->data()->data());
     1151        if (m_unpackAlignment != 1)
     1152            m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
     1153
    11581154        return { };
    1159 
    1160     if (imageForRender->isSVGImage())
    1161         imageForRender = drawImageIntoBuffer(*imageForRender, image->width(), image->height(), 1);
    1162    
    1163     if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLImageElement, target, level, GraphicsContext3D::NONE, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
     1155    }, [&](const RefPtr<HTMLImageElement>& image) -> ExceptionOr<void> {
     1156        if (wouldTaintOrigin(image.get()))
     1157            return Exception { SECURITY_ERR };
     1158        if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image.get()))
     1159            return { };
     1160
     1161        RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
     1162        if (!imageForRender)
     1163            return { };
     1164
     1165        if (imageForRender->isSVGImage())
     1166            imageForRender = drawImageIntoBuffer(*imageForRender, image->width(), image->height(), 1);
     1167
     1168        if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLImageElement, target, level, GraphicsContext3D::NONE, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
     1169            return { };
     1170
     1171        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
    11641172        return { };
    1165    
    1166     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
    1167     return { };
    1168 }
    1169 
    1170 ExceptionOr<void> WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas)
    1171 {
    1172     if (wouldTaintOrigin(canvas))
    1173         return Exception { SECURITY_ERR };
    1174     if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas)
    1175         || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, GraphicsContext3D::NONE, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset))
     1173    }, [&](const RefPtr<HTMLCanvasElement>& canvas) -> ExceptionOr<void> {
     1174        if (wouldTaintOrigin(canvas.get()))
     1175            return Exception { SECURITY_ERR };
     1176        if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas.get())
     1177            || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, GraphicsContext3D::NONE, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset))
     1178            return { };
     1179
     1180        RefPtr<ImageData> imageData = canvas->getImageData();
     1181        if (imageData)
     1182            texSubImage2D(target, level, xoffset, yoffset, format, type, TexImageSource(imageData.get()));
     1183        else
     1184            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
    11761185        return { };
    1177 
    1178     RefPtr<ImageData> imageData = canvas->getImageData();
    1179     if (imageData)
    1180         texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get());
    1181     else
    1182         texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
    1183     return { };
    1184 }
    1185 
    1186 #if ENABLE(VIDEO)
    1187 
    1188 ExceptionOr<void> WebGL2RenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement* video)
    1189 {
    1190     if (wouldTaintOrigin(video))
    1191         return Exception { SECURITY_ERR };
    1192     if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video)
    1193         || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, GraphicsContext3D::NONE, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
     1186    }, [&](const RefPtr<HTMLVideoElement>& video) -> ExceptionOr<void> {
     1187        if (wouldTaintOrigin(video.get()))
     1188            return Exception { SECURITY_ERR };
     1189        if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video.get())
     1190            || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, GraphicsContext3D::NONE, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
     1191            return { };
     1192
     1193        RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
     1194        if (!image)
     1195            return { };
     1196        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
    11941197        return { };
    1195 
    1196     RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode());
    1197     if (!image)
    1198         return { };
    1199     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
    1200     return { };
    1201 }
    1202 
    1203 #endif
     1198    });
     1199
     1200    return WTF::visit(visitor, source.value());
     1201}
    12041202
    12051203bool WebGL2RenderingContext::validateTexFuncParameters(const char* functionName, TexFuncValidationFunctionType functionType, GC3Denum target, GC3Dint level, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height, GC3Dint border, GC3Denum format, GC3Denum type)
  • trunk/Source/WebCore/html/canvas/WebGL2RenderingContext.h

    r207720 r207724  
    183183    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha) final;
    184184    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&) final;
    185     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData*) final;
    186     ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement*) final;
    187     ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement*) final;
    188 #if ENABLE(VIDEO)
    189     ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement*) final;
    190 #endif
     185    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Optional<TexImageSource>&&) final;
    191186
    192187    void initializeVertexArrayObjects() final;
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r207720 r207724  
    587587}
    588588
    589 void WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData* pixels)
    590 {
    591     if (isContextLostOrPending() || !pixels || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, format,  pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset))
    592         return;
    593    
    594     Vector<uint8_t> data;
    595     bool needConversion = true;
    596     // The data from ImageData is always of format RGBA8.
    597     // No conversion is needed if destination format is RGBA and type is USIGNED_BYTE and no Flip or Premultiply operation is required.
    598     if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha)
    599         needConversion = false;
    600     else {
    601         if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
    602             synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
    603             return;
    604         }
    605     }
    606     if (m_unpackAlignment != 1)
    607         m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
    608    
    609     texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), format, format, type, needConversion ? data.data() : pixels->data()->data());
    610     if (m_unpackAlignment != 1)
    611         m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
    612 }
    613 
    614 ExceptionOr<void> WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement* image)
    615 {
    616     if (wouldTaintOrigin(image))
    617         return Exception { SECURITY_ERR };
    618     if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image))
     589ExceptionOr<void> WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Optional<TexImageSource>&& source)
     590{
     591    if (!source) {
     592        synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "source is null");
    619593        return { };
    620 
    621     RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
    622     if (!imageForRender)
     594    }
     595
     596    auto visitor = WTF::makeVisitor([&](const RefPtr<ImageData>& pixels) -> ExceptionOr<void> {
     597        if (isContextLostOrPending() || !validateTexFunc("texSubImage2D", TexSubImage, SourceImageData, target, level, format,  pixels->width(), pixels->height(), 0, format, type, xoffset, yoffset))
     598            return { };
     599
     600        Vector<uint8_t> data;
     601        bool needConversion = true;
     602        // The data from ImageData is always of format RGBA8.
     603        // No conversion is needed if destination format is RGBA and type is USIGNED_BYTE and no Flip or Premultiply operation is required.
     604        if (format == GraphicsContext3D::RGBA && type == GraphicsContext3D::UNSIGNED_BYTE && !m_unpackFlipY && !m_unpackPremultiplyAlpha)
     605            needConversion = false;
     606        else {
     607            if (!m_context->extractImageData(pixels.get(), format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) {
     608                synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "texSubImage2D", "bad image data");
     609                return { };
     610            }
     611        }
     612        if (m_unpackAlignment != 1)
     613            m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, 1);
     614
     615        texSubImage2DBase(target, level, xoffset, yoffset, pixels->width(), pixels->height(), format, format, type, needConversion ? data.data() : pixels->data()->data());
     616        if (m_unpackAlignment != 1)
     617            m_context->pixelStorei(GraphicsContext3D::UNPACK_ALIGNMENT, m_unpackAlignment);
     618
    623619        return { };
    624 
    625     if (imageForRender->isSVGImage())
    626         imageForRender = drawImageIntoBuffer(*imageForRender, image->width(), image->height(), 1);
    627    
    628     if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLImageElement, target, level, format, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
     620    } , [&](const RefPtr<HTMLImageElement>& image) -> ExceptionOr<void> {
     621        if (wouldTaintOrigin(image.get()))
     622            return Exception { SECURITY_ERR };
     623        if (isContextLostOrPending() || !validateHTMLImageElement("texSubImage2D", image.get()))
     624            return { };
     625
     626        RefPtr<Image> imageForRender = image->cachedImage()->imageForRenderer(image->renderer());
     627        if (!imageForRender)
     628            return { };
     629
     630        if (imageForRender->isSVGImage())
     631            imageForRender = drawImageIntoBuffer(*imageForRender, image->width(), image->height(), 1);
     632
     633        if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLImageElement, target, level, format, imageForRender->width(), imageForRender->height(), 0, format, type, xoffset, yoffset))
     634            return { };
     635
     636        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
    629637        return { };
    630 
    631     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRender.get(), GraphicsContext3D::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha);
    632     return { };
    633 }
    634 
    635 ExceptionOr<void> WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement* canvas)
    636 {
    637     if (wouldTaintOrigin(canvas))
    638         return Exception { SECURITY_ERR };
    639     if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas)
    640         || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset))
     638    }, [&](const RefPtr<HTMLCanvasElement>& canvas) -> ExceptionOr<void> {
     639        if (wouldTaintOrigin(canvas.get()))
     640            return Exception { SECURITY_ERR };
     641        if (isContextLostOrPending() || !validateHTMLCanvasElement("texSubImage2D", canvas.get())
     642            || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElement, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset))
     643            return { };
     644
     645        RefPtr<ImageData> imageData = canvas->getImageData();
     646        if (imageData)
     647            texSubImage2D(target, level, xoffset, yoffset, format, type, TexImageSource(imageData.get()));
     648        else
     649            texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
    641650        return { };
    642 
    643     RefPtr<ImageData> imageData = canvas->getImageData();
    644     if (imageData)
    645         texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.get());
    646     else
    647         texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas->copiedImage(), GraphicsContext3D::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultiplyAlpha);
    648     return { };
    649 }
    650 
    651 #if ENABLE(VIDEO)
    652 
    653 ExceptionOr<void> WebGLRenderingContext::texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement* video)
    654 {
    655     if (wouldTaintOrigin(video))
    656         return Exception { SECURITY_ERR };
    657     if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video)
    658         || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
     651    }, [&](const RefPtr<HTMLVideoElement>& video) -> ExceptionOr<void> {
     652        if (wouldTaintOrigin(video.get()))
     653            return Exception { SECURITY_ERR };
     654        if (isContextLostOrPending() || !validateHTMLVideoElement("texSubImage2D", video.get())
     655            || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
     656            return { };
     657
     658        RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
     659        if (!image)
     660            return { };
     661        texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
    659662        return { };
    660 
    661     RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMode());
    662     if (!image)
    663         return { };
    664     texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContext3D::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha);
    665     return { };
    666 }
    667 
    668 #endif
     663    });
     664
     665    return WTF::visit(visitor, source.value());
     666}
    669667
    670668bool WebGLRenderingContext::validateTexFuncParameters(const char* functionName,
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r207720 r207724  
    5151    void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha) final;
    5252    void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&) final;
    53     void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData*) final;
    54     ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement*) final;
    55     ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement*) final;
    56 #if ENABLE(VIDEO)
    57     ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement*) final;
    58 #endif
     53    ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Optional<TexImageSource>&&) final;
    5954
    6055    GC3Dint getMaxDrawBuffers() final;
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h

    r207720 r207724  
    248248
    249249    virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, RefPtr<ArrayBufferView>&&) = 0;
    250     virtual void texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, ImageData*) = 0;
    251     virtual ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLImageElement*) = 0;
    252     virtual ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLCanvasElement*) = 0;
    253 #if ENABLE(VIDEO)
    254     virtual ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, HTMLVideoElement*) = 0;
    255 #endif
     250    virtual ExceptionOr<void> texSubImage2D(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Optional<TexImageSource>&&) = 0;
    256251
    257252    void uniform1f(const WebGLUniformLocation*, GC3Dfloat x);
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.idl

    r207720 r207724  
    620620
    621621    void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, ArrayBufferView? pixels);
    622     void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, ImageData? pixels);
    623     [MayThrowException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLImageElement? image);
    624     [MayThrowException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLCanvasElement? canvas);
    625     [Conditional=VIDEO, MayThrowException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, HTMLVideoElement? video);
     622    [MayThrowException] void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLenum format, GLenum type, TexImageSource? source);
    626623
    627624    void uniform1f(WebGLUniformLocation? location, GLfloat x);
Note: See TracChangeset for help on using the changeset viewer.