gecko-dev/dom/canvas
Lee Salzman 3c994f8afd Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel
This mainly provides DrawTargetWebgl, which implements the subset of the DrawTarget
API necessary for integration with CanvasRenderingContext2D. It translates them to
suitable commands for its internal ClientWebGLContext, which then manages remoting
WebGL requests to the parent/GPU process.

Currently two shaders are used for drawing Canvas2D primitives, but can be expanded
in the future. These are an image shader and a solid color shader.

The core of this implementation revolves around TexturePacker and TextureHandle,
which cope with the necessity of frequently uploading SourceSurfaces for use with
WebGL. TexturePacker implements a bin-packing algorithm for packing these uploads
into texture pages, which can either be SharedTextures if they are reasonably small,
or StandaloneTextures if they are too big to pack in a SharedTexture. Each upload
is assigned a TextureHandle which is used to manage it in a move-to-front cache,
so that we can easily eject TextureHandles from the back of the cache if we have
too many. These TextureHandles are associated with the SourceSurface that spawned
them to more easily manage their lifetimes.

There are further dependent caches for dealing with blurred shadows and with text.
Shadows are cached in an uploaded texture bound to the SourceSurface that generated
them. Text is handled by caching entire runs in the GlyphCache (keyed by both their
rendering parameters and their glyphs). The text is first rasterized to a surface
and then uploaded to a texture in the GlyphCache which can be reused should the
text be encountered again.

To deal with commands we can't accelerate, a separate internal DrawTargetSkia is
also maintained. The content of the WebGL framebuffer is copied into it so that
drawing can then proceed in software from there. It remains in this fallover state
until the next frame, when it resets back to using the WebGL framebuffer again.

This acceleration is disabled by default. To enable it, you must toggle the pref
"gfx.canvas.accelerated" to true. This should be suitably different from the naming
of the previous SkiaGL prefs to not alias with them. There are a few dependent prefs
that follow from the previous SkiaGL prefs for setting the size limitations for
acceleration and also limitations for the internal texture cache.

Differential Revision: https://phabricator.services.mozilla.com/D130388
2021-11-11 07:16:58 +00:00
..
crashtests Bug 1733921 - Simplify reftest annotations to assume WebRender is on. r=gfx-reviewers,jrmuizel 2021-10-04 13:14:37 +00:00
gtest Bug 1726588 - Sanitize AMD ARUBA RENDERER. r=gcp,jgilbert 2021-10-12 17:34:05 +00:00
test Bug 1724331. Add a test. r=aosmond 2021-11-05 08:53:28 +00:00
BasicRenderingContext2D.h Bug 1627014 - Implement CanvasRenderingContext2D.createConicGradient r=emilio 2021-01-01 01:50:52 +00:00
CacheInvalidator.cpp
CacheInvalidator.h Bug 1723050 - Part 6: Replace typedef by using in dom/canvas/ r=jgilbert 2021-07-30 15:30:52 +00:00
CanvasGradient.cpp Bug 1684173 - Add newline character at end of files when missing r=sylvestre,geckoview-reviewers,agi 2021-01-07 08:53:08 +00:00
CanvasGradient.h Bug 1697344 p3: Don't hold the GradientStops object on CanvasGradient. r=jrmuizel 2021-03-29 12:12:21 +00:00
CanvasImageCache.cpp Bug 1723050 - Part 6: Replace typedef by using in dom/canvas/ r=jgilbert 2021-07-30 15:30:52 +00:00
CanvasImageCache.h Bug 1723050 - Part 6: Replace typedef by using in dom/canvas/ r=jgilbert 2021-07-30 15:30:52 +00:00
CanvasPath.h
CanvasPattern.cpp Bug 1684173 - Add newline character at end of files when missing r=sylvestre,geckoview-reviewers,agi 2021-01-07 08:53:08 +00:00
CanvasPattern.h
CanvasRenderingContext2D.cpp Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
CanvasRenderingContext2D.h Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
CanvasRenderingContextHelper.cpp Bug 1693003 - Remove redundant nullptr checks of return value of infallible new in dom/. r=smaug 2021-02-16 15:52:10 +00:00
CanvasRenderingContextHelper.h
CanvasUtils.cpp Bug 1726626 - Move gfx/wgpu into a 3rd party dependency r=jgilbert,bholley 2021-09-03 16:52:08 +00:00
CanvasUtils.h Bug 1708448 - Move property and element functions into js/public/PropertyAndElement.h. r=nbp 2021-07-13 11:52:42 +00:00
ClientWebGLContext.cpp Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
ClientWebGLContext.h Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
ClientWebGLExtensions.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
ClientWebGLExtensions.h Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
DrawTargetWebgl.cpp Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
DrawTargetWebgl.h Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
DrawTargetWebglInternal.h Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
GeneratePlaceholderCanvasData.h
HostWebGLContext.cpp Bug 1727489 - Remove PLayerTransaction. r=jrmuizel,jgilbert 2021-08-26 04:59:57 +00:00
HostWebGLContext.h Backed out 3 changesets (bug 1736066) for causing webgl failures in gfx/2d/Logging. CLOSED TREE 2021-10-28 22:10:39 +03:00
ImageBitmap.cpp Bug 1367251 - add bindings for options to createImageBitmap and support flipY r=bzbarsky,aosmond,baku 2021-09-02 00:29:29 +00:00
ImageBitmap.h Bug 1367251 - add bindings for options to createImageBitmap and support flipY r=bzbarsky,aosmond,baku 2021-09-02 00:29:29 +00:00
ImageBitmapRenderingContext.cpp Bug 1728903 - Remove plumbing for CanvasLayer and ImageLayer. r=mattwoodrow 2021-09-18 11:44:51 +00:00
ImageBitmapRenderingContext.h Bug 1728903 - Remove plumbing for CanvasLayer and ImageLayer. r=mattwoodrow 2021-09-18 11:44:51 +00:00
ImageBitmapSource.h
ImageData.cpp Bug 1712725 - Stop clearing JS things when calling mozilla::DropJSObjects. r=mccr8 2021-05-27 08:35:40 +00:00
ImageData.h
ImageUtils.cpp
ImageUtils.h
MurmurHash3.cpp
MurmurHash3.h Bug 1684173 - Add newline character at end of files when missing r=sylvestre,geckoview-reviewers,agi 2021-01-07 08:53:08 +00:00
OffscreenCanvas.cpp Bug 1735874 - Fix broken resist fingerprinting with OffscreenCanvas on worker threads. r=dom-worker-reviewers,asuth,smaug 2021-11-09 20:16:04 +00:00
OffscreenCanvas.h Bug 1735874 - Fix broken resist fingerprinting with OffscreenCanvas on worker threads. r=dom-worker-reviewers,asuth,smaug 2021-11-09 20:16:04 +00:00
PWebGL.ipdl Bug 1734649 - Part 3. Switch to always allocating PWebGL instances via CanvasManager. r=jgilbert 2021-11-04 16:29:44 +00:00
QueueParamTraits.h Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman 2021-09-11 02:11:11 +00:00
SanitizeRenderer.cpp Bug 1737093 use empty instead of size r=sylvestre 2021-11-04 19:01:52 +00:00
TexUnpackBlob.cpp Bug 1367251 - ignore gl.UNPACK_FLIP_Y_WEBGL & UNPACK_PREMULTIPLY_ALPHA for textures uploading ImageBitmap data as per spec. r=jgilbert 2021-09-02 00:29:28 +00:00
TexUnpackBlob.h Bug 1640607 - Send SurfaceDescriptors for GPU blitting for video-to-webgl. r=lsalzman 2021-01-14 01:23:06 +00:00
TextMetrics.h
WebGL2Context.cpp
WebGL2Context.h
WebGL2ContextBuffers.cpp
WebGL2ContextFramebuffers.cpp
WebGL2ContextMRTs.cpp
WebGL2ContextQueries.cpp
WebGL2ContextRenderbuffers.cpp
WebGL2ContextSamplers.cpp
WebGL2ContextState.cpp
WebGL2ContextSync.cpp
WebGL2ContextTransformFeedback.cpp
WebGL2ContextUniforms.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLBuffer.cpp
WebGLBuffer.h
WebGLChild.cpp Bug 1699201 - Pretty-print Deserialize failure func name and badArgId. r=lsalzman 2021-04-17 03:45:10 +00:00
WebGLChild.h Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman 2021-09-11 02:11:11 +00:00
WebGLCommandQueue.h Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman 2021-09-11 02:11:11 +00:00
WebGLContext.cpp Bug 1661869 - Fix screenshotting of WebGL canvases. r=gfx-reviewers,lsalzman 2021-09-18 01:23:58 +00:00
WebGLContext.h Bug 1728903 - Remove plumbing for CanvasLayer and ImageLayer. r=mattwoodrow 2021-09-18 11:44:51 +00:00
WebGLContextBuffers.cpp
WebGLContextDraw.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLContextExtensions.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLContextFramebufferOperations.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLContextGL.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLContextLossHandler.cpp
WebGLContextLossHandler.h
WebGLContextState.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLContextTextures.cpp Bug 1692832 - isTexUploadFromPbo iff isPboBound. r=lsalzman 2021-03-10 18:35:16 +00:00
WebGLContextUtils.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLContextUtils.h
WebGLContextValidate.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLContextVertexArray.cpp
WebGLContextVertices.cpp Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman 2021-09-11 02:11:11 +00:00
WebGLExtensions.cpp Bug 1735431 - Merge WebGLExtension* into WebGLExtensions.cpp. r=gfx-reviewers,nical 2021-10-19 23:07:00 +00:00
WebGLExtensions.h Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLFormats.cpp Bug 1739688 - Mark WebGL2 depth formats as non-filterable. r=gfx-reviewers,lsalzman 2021-11-08 19:44:27 +00:00
WebGLFormats.h Bug 1723050 - Part 6: Replace typedef by using in dom/canvas/ r=jgilbert 2021-07-30 15:30:52 +00:00
WebGLFramebuffer.cpp Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLFramebuffer.h Bug 1734285 - fix mixing bitwise with bool operators. r=emilio 2021-10-06 17:37:56 +00:00
WebGLInternalFormatsTable.h
WebGLIpdl.h Backed out 2 changesets (bug 1720965) for causing bustages on nsContentUtils.cpp. CLOSED TREE 2021-08-04 03:14:29 +03:00
WebGLMemoryTracker.cpp
WebGLMemoryTracker.h
WebGLMethodDispatcher.h Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLObjectModel.h
WebGLParent.cpp Bug 1727729 - Check HostWebGLContext initialization in WebGLParent. r=jgilbert 2021-10-14 19:52:26 +00:00
WebGLParent.h Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman 2021-09-11 02:11:11 +00:00
WebGLProgram.cpp Bug 1738125 - Include failed compile log in LinkProgram failure warning. r=gfx-reviewers,bradwerth 2021-10-27 22:44:58 +00:00
WebGLProgram.h Bug 1726265 - Prototype webgl draft ext OES_draw_buffers_indexed. r=lsalzman,emilio,webidl 2021-08-27 01:47:14 +00:00
WebGLQuery.cpp
WebGLQuery.h
WebGLQueueParamTraits.h Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman 2021-09-11 02:11:11 +00:00
WebGLRenderbuffer.cpp
WebGLRenderbuffer.h
WebGLSampler.cpp
WebGLSampler.h
WebGLShader.cpp Bug 1725069 - Allow GLSL-invalid chars in shaderSource. r=gfx-reviewers,kvark 2021-09-16 20:19:11 +00:00
WebGLShader.h
WebGLShaderValidator.cpp Bug 1717151 - Prep ANGLE for vendoring. r=gfx-reviewers,kvark 2021-09-16 18:24:28 +00:00
WebGLShaderValidator.h
WebGLStrongTypes.h
WebGLSync.cpp
WebGLSync.h
WebGLTexelConversions.cpp Bug 1723050 - Part 6: Replace typedef by using in dom/canvas/ r=jgilbert 2021-07-30 15:30:52 +00:00
WebGLTexelConversions.h Bug 1723050 - Part 6: Replace typedef by using in dom/canvas/ r=jgilbert 2021-07-30 15:30:52 +00:00
WebGLTexture.cpp Bug 1696075 - Match spec for webgl sampling feedback detection. r=lsalzman 2021-03-04 03:14:50 +00:00
WebGLTexture.h Bug 1696075 - Match spec for webgl sampling feedback detection. r=lsalzman 2021-03-04 03:14:50 +00:00
WebGLTextureUpload.cpp Bug 1367251 - ignore gl.UNPACK_FLIP_Y_WEBGL & UNPACK_PREMULTIPLY_ALPHA for textures uploading ImageBitmap data as per spec. r=jgilbert 2021-09-02 00:29:28 +00:00
WebGLTransformFeedback.cpp Bug 1715690 - Generalize WebGL RENDERER into large buckets. r=lsalzman 2021-06-14 21:27:08 +00:00
WebGLTransformFeedback.h
WebGLTypes.h Bug 1730282 - Cleanup IPC WebGL code. r=gfx-reviewers,lsalzman 2021-09-11 02:11:11 +00:00
WebGLValidateStrings.cpp Bug 1725069 - Allow GLSL-invalid chars in shaderSource. r=gfx-reviewers,kvark 2021-09-16 20:19:11 +00:00
WebGLValidateStrings.h Bug 1725069 - Allow GLSL-invalid chars in shaderSource. r=gfx-reviewers,kvark 2021-09-16 20:19:11 +00:00
WebGLVertexArray.cpp
WebGLVertexArray.h
WebGLVertexArrayFake.cpp
WebGLVertexArrayFake.h
WebGLVertexArrayGL.cpp
WebGLVertexArrayGL.h
XRWebGLLayer.cpp Bug 1712725 - Stop clearing JS things when calling mozilla::DropJSObjects. r=mccr8 2021-05-27 08:35:40 +00:00
XRWebGLLayer.h
moz.build Bug 1739448 - Implement a prototype WebGL-backed Canvas2D. r=gfx-reviewers,nical,jrmuizel 2021-11-11 07:16:58 +00:00
nsICanvasRenderingContextInternal.cpp
nsICanvasRenderingContextInternal.h Bug 1728903 - Remove plumbing for CanvasLayer and ImageLayer. r=mattwoodrow 2021-09-18 11:44:51 +00:00