Source/Platform/ChangeLog

 12012-06-20 Jeff Timanus <twiz@chromium.org>
 2
 3 [Chromium] Change implementing a fast-path for copying GPU-accelerated Canvas2D instances to WebGL textures.
 4 https://bugs.webkit.org/show_bug.cgi?id=86275
 5
 6 This change adds the necessary plumbing to the various rendering contexts to copy the backing store texture of a Canvas2D
 7 instance to be copied to a WebGL texture. The GL_CHROMIUM_copy_texture extension is necessary because the backing-store
 8 for a GPU-accelerated skia Canvas2D is normally in BGRA format, which is not supported by glCopyTexImage.
 9
 10 Reviewed by NOBODY (OOPS!).
 11
 12 * chromium/public/WebGraphicsContext3D.h:
 13 (WebGraphicsContext3D):
 14 (WebKit::WebGraphicsContext3D::copyTextureCHROMIUM):
 15
1162012-06-19 Tony Payne <tpayne@chromium.org>
217
318 Add monitor profile support for Win
120843

Source/Platform/chromium/public/WebGraphicsContext3D.h

@@public:
411411 virtual void getQueryivEXT(WGC3Denum target, WGC3Denum pname, WGC3Dint* params) { }
412412 virtual void getQueryObjectuivEXT(WebGLId query, WGC3Denum pname, WGC3Duint* params) { }
413413
 414 // GL_CHROMIUM_copy_texture
 415 virtual void copyTextureCHROMIUM(WGC3Denum target, WGC3Duint sourceId,
 416 WGC3Duint destId, WGC3Dint level, WGC3Denum internalFormat) { }
 417
414418 GrGLInterface* createGrGLInterface();
415419
416420protected:
120101

Source/WebCore/ChangeLog

 12012-06-20 Jeff Timanus <twiz@chromium.org>
 2
 3 [Chromium] Change implementing a fast-path for copying GPU-accelerated Canvas2D instances to WebGL textures.
 4 https://bugs.webkit.org/show_bug.cgi?id=86275
 5
 6 This change adds the necessary plumbing to the various rendering contexts to copy the backing store texture of a Canvas2D
 7 instance to be copied to a WebGL texture. The GL_CHROMIUM_copy_texture extension is necessary because the backing-store
 8 for a GPU-accelerated skia Canvas2D is normally in BGRA format, which is not supported by glCopyTexImage.
 9
 10 Reviewed by NOBODY (OOPS!).
 11
 12 Test: fast/canvas/webgl/*
 13
 14 * html/canvas/WebGLRenderingContext.cpp:
 15 (WebCore):
 16 (WebCore::WebGLRenderingContext::texImage2D):
 17 * platform/chromium/support/Extensions3DChromium.cpp:
 18 (WebCore::Extensions3DChromium::copyTextureCHROMIUM):
 19 (WebCore):
 20 * platform/graphics/Extensions3D.h:
 21 (Extensions3D):
 22 * platform/graphics/ImageBuffer.cpp:
 23 (WebCore):
 24 (WebCore::ImageBuffer::copyToPlatformTexture):
 25 * platform/graphics/ImageBuffer.h:
 26 (WebCore):
 27 (ImageBuffer):
 28 * platform/graphics/chromium/Canvas2DLayerBridge.cpp:
 29 (WebCore::Canvas2DLayerBridge::backBufferTexture):
 30 (WebCore):
 31 * platform/graphics/chromium/Canvas2DLayerBridge.h:
 32 (Canvas2DLayerBridge):
 33 * platform/graphics/chromium/Extensions3DChromium.h:
 34 (Extensions3DChromium):
 35 * platform/graphics/opengl/Extensions3DOpenGL.cpp:
 36 (WebCore::Extensions3DOpenGL::copyTextureCHROMIUM):
 37 (WebCore):
 38 * platform/graphics/opengl/Extensions3DOpenGL.h:
 39 (Extensions3DOpenGL):
 40 * platform/graphics/qt/Extensions3DQt.cpp:
 41 (WebCore::Extensions3DQt::copyTextureCHROMIUM):
 42 (WebCore):
 43 * platform/graphics/qt/Extensions3DQt.h:
 44 (Extensions3DQt):
 45 * platform/graphics/skia/ImageBufferSkia.cpp:
 46 (WebCore::ImageBuffer::platformLayer):
 47 (WebCore):
 48 (WebCore::ImageBuffer::copyToPlatformTexture):
 49
1502012-06-20 Andrey Adaikin <aandrey@chromium.org>
251
352 Web Inspector: Allow module injections into the InjectedScript
120843

Source/WebCore/html/canvas/WebGLRenderingContext.cpp

@@void WebGLRenderingContext::texImage2D(G
36123612 ec = SECURITY_ERR;
36133613 return;
36143614 }
 3615
 3616 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
 3617 // If possible, copy from the canvas element directly to the texture
 3618 // via the GPU, without a read-back to system memory.
 3619 if (GraphicsContext3D::TEXTURE_2D == target && texture && type == texture->getType(target, level)) {
 3620 ImageBuffer* buffer = canvas->buffer();
 3621 if (buffer && buffer->copyToPlatformTexture(*m_context.get(), texture->object(), internalformat, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
 3622 texture->setLevelInfo(target, level, internalformat, canvas->width(), canvas->height(), type);
 3623 cleanupAfterGraphicsCall(false);
 3624 return;
 3625 }
 3626 }
 3627
36153628 RefPtr<ImageData> imageData = canvas->getImageData();
36163629 if (imageData)
36173630 texImage2D(target, level, internalformat, format, type, imageData.get(), ec);
120101

Source/WebCore/platform/chromium/support/Extensions3DChromium.cpp

@@void Extensions3DChromium::getQueryObjec
201201 m_private->webContext()->getQueryObjectuivEXT(query, pname, params);
202202}
203203
 204void Extensions3DChromium::copyTextureCHROMIUM(GC3Denum target, Platform3DObject sourceId, Platform3DObject destId, GC3Dint level, GC3Denum internalFormat)
 205{
 206 m_private->webContext()->copyTextureCHROMIUM(target, sourceId, destId, level, internalFormat);
 207}
 208
204209} // namespace WebCore
120101

Source/WebCore/platform/graphics/Extensions3D.h

@@public:
6666 // GL_OES_compressed_ETC1_RGB8_texture
6767 // GL_IMG_texture_compression_pvrtc
6868 // EXT_texture_filter_anisotropic
 69 // GL_CHROMIUM_copy_texture
 70 // GL_CHROMIUM_flipy
6971
7072 // Takes full name of extension; for example,
7173 // "GL_EXT_texture_format_BGRA8888".

@@public:
140142 // GL_EXT_texture_filter_anisotropic
141143 TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE,
142144 MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF,
 145
 146 // GL_CHROMIUM_flipy
 147 UNPACK_FLIP_Y_CHROMIUM = 0x9240,
 148
 149 // GL_CHROMIUM_copy_texture
 150 UNPACK_PREMULTIPLY_ALPHA_CHROMIUM = 0x9241,
 151 UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM = 0x9242
143152 };
144153
145154 // GL_ARB_robustness

@@public:
165174
166175 // GL_ANGLE_translated_shader_source
167176 virtual String getTranslatedShaderSourceANGLE(Platform3DObject) = 0;
 177
 178 // GL_CHROMIUM_copy_texture
 179 virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum) = 0;
168180};
169181
170182} // namespace WebCore
120101

Source/WebCore/platform/graphics/ImageBuffer.cpp

@@PlatformLayer* ImageBuffer::platformLaye
105105}
106106#endif
107107
 108#if !USE(SKIA)
 109bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denum, bool, bool)
 110{
 111 return false;
 112}
 113#endif
 114
108115}
120101

Source/WebCore/platform/graphics/ImageBuffer.h

3636#include "GraphicsLayer.h"
3737#endif
3838#include "GraphicsTypes.h"
 39#include "GraphicsTypes3D.h"
3940#include "IntSize.h"
4041#include "ImageBufferData.h"
4142#include <wtf/Forward.h>

@@namespace WebCore {
5152 class ImageData;
5253 class IntPoint;
5354 class IntRect;
 55 class GraphicsContext3D;
5456
5557 enum Multiply {
5658 Premultiplied,

@@namespace WebCore {
117119 PlatformLayer* platformLayer() const;
118120#endif
119121
 122 bool copyToPlatformTexture(GraphicsContext3D&, Platform3DObject, GC3Denum, bool, bool);
 123
120124 private:
121125#if USE(CG)
122126 NativeImagePtr copyNativeImage(BackingStoreCopy = CopyBackingStore) const;
120101

Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.cpp

@@void Canvas2DLayerBridge::contextAcquire
155155 m_layer->willModifyTexture();
156156}
157157
 158unsigned Canvas2DLayerBridge::backBufferTexture()
 159{
 160 contextAcquired();
 161 if (m_canvas)
 162 m_canvas->flush();
 163 m_context->flush();
 164 return m_backBufferTexture;
 165}
 166
158167}
159168
120101

Source/WebCore/platform/graphics/chromium/Canvas2DLayerBridge.h

@@public:
6262 LayerChromium* layer() const;
6363 void contextAcquired();
6464
 65 unsigned backBufferTexture();
 66
6567private:
6668 Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D>, const IntSize&, DeferralMode, unsigned textureId);
6769
120101

Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h

@@public:
156156 void getQueryivEXT(GC3Denum, GC3Denum, GC3Dint*);
157157 void getQueryObjectuivEXT(Platform3DObject, GC3Denum, GC3Duint*);
158158
 159 // GL_CHROMIUM_copy_texture
 160 void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum);
 161
159162private:
160163 // Instances of this class are strictly owned by the GraphicsContext3D implementation and do not
161164 // need to be instantiated by any other code.
120101

Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp

@@String Extensions3DOpenGL::getTranslated
201201 // FIXME: implement this function and add GL_ANGLE_translated_shader_source in supports().
202202}
203203
 204void Extensions3DOpenGL::copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum)
 205{
 206 // FIXME: implement this function and add GL_CHROMIUM_copy_texture in supports().
 207 return;
 208}
 209
204210} // namespace WebCore
205211
206212#endif // ENABLE(WEBGL)
120101

Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h

@@public:
5151 virtual GC3Dboolean isVertexArrayOES(Platform3DObject);
5252 virtual void bindVertexArrayOES(Platform3DObject);
5353 virtual String getTranslatedShaderSourceANGLE(Platform3DObject);
 54 virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum);
5455
5556private:
5657 // This class only needs to be instantiated by GraphicsContext3D implementations.
120101

Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp

@@String Extensions3DQt::getTranslatedShad
9393 return "";
9494}
9595
 96void Extensions3DQt::copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum)
 97{
 98 return;
 99}
 100
96101} // namespace WebCore
97102
98103#endif // ENABLE(WEBGL)
120101

Source/WebCore/platform/graphics/qt/Extensions3DQt.h

@@public:
4646 virtual GC3Dboolean isVertexArrayOES(Platform3DObject);
4747 virtual void bindVertexArrayOES(Platform3DObject);
4848 virtual String getTranslatedShaderSourceANGLE(Platform3DObject);
 49 virtual void copyTextureCHROMIUM(GC3Denum, Platform3DObject, Platform3DObject, GC3Dint, GC3Denum);
4950
5051private:
5152 // This class only needs to be instantiated by GraphicsContext3D implementations.
120101

Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp

3636#include "Base64.h"
3737#include "BitmapImage.h"
3838#include "BitmapImageSingleFrameSkia.h"
 39#include "Extensions3D.h"
3940#include "GrContext.h"
4041#include "GraphicsContext.h"
 42#include "GraphicsContext3D.h"
4143#include "ImageData.h"
4244#include "JPEGImageEncoder.h"
4345#include "MIMETypeRegistry.h"

@@PlatformLayer* ImageBuffer::platformLaye
166168 return m_data.m_layerBridge ? m_data.m_layerBridge->layer() : 0;
167169}
168170
 171bool ImageBuffer::copyToPlatformTexture(GraphicsContext3D& context, Platform3DObject texture, GC3Denum internalFormat, bool premultiplyAlpha, bool flipY)
 172{
 173 if (!m_data.m_layerBridge || !platformLayer())
 174 return false;
 175
 176 Platform3DObject sourceTexture = m_data.m_layerBridge->backBufferTexture();
 177
 178 if (!context.makeContextCurrent())
 179 return false;
 180
 181 Extensions3D* extensions = context.getExtensions();
 182 if (!extensions->supports("GL_CHROMIUM_copy_texture") || !extensions->supports("GL_CHROMIUM_flipy"))
 183 return false;
 184
 185 // The canvas is stored in a premultiplied format, so unpremultiply if necessary.
 186 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, !premultiplyAlpha);
 187
 188 // The canvas is stored in an inverted position, so the flip semantics are reversed.
 189 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, !flipY);
 190
 191 extensions->copyTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D, sourceTexture, texture, 0, internalFormat);
 192
 193 context.pixelStorei(Extensions3D::UNPACK_FLIP_Y_CHROMIUM, false);
 194 context.pixelStorei(Extensions3D::UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, false);
 195 return true;
 196}
 197
169198void ImageBuffer::clip(GraphicsContext* context, const FloatRect& rect) const
170199{
171200 context->platformContext()->beginLayerClippedToImage(rect, this);
120101