Commit 8f1cfedd authored by Kenneth Russell's avatar Kenneth Russell Committed by Commit Bot

Refactor WebGL texture uploading from DOM sources.

The current code was fragile, relying on only approximate answers
about whether a canvas was accelerated or not.

Refactor the upload paths for canvases and ImageBitmaps to properly
make the decision about whether to take the GPU or CPU based upload
path based on whether the resource they receive (usually an Image) is
texture-backed. Replace TexImageCanvasByGPU and TexImageBitmapByGPU
with a single TexImageViaGPU.

More refactorings are possible, and will be built on this. This CL is
being kept self-contained for backport to earlier releases.

Tested with new conformance test in
https://github.com/KhronosGroup/WebGL/pull/2706 .

Bug: 878545
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I8a2653ef9f4a0cc6a36ba381941f5c30c94a57d8
Reviewed-on: https://chromium-review.googlesource.com/1217856
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarKai Ninomiya <kainino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591096}
parent 079d8c6e
......@@ -69,6 +69,7 @@ class GLES2Interface;
namespace blink {
class AcceleratedStaticBitmapImage;
class CanvasResourceProvider;
class EXTDisjointTimerQuery;
class EXTDisjointTimerQueryWebGL2;
......@@ -1054,7 +1055,6 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
const IntRect&,
GLsizei depth,
GLint unpack_image_height);
template <typename T>
IntRect GetTextureSourceSize(T* texture_source) {
return IntRect(0, 0, texture_source->width(), texture_source->height());
......@@ -1141,19 +1141,6 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
return true;
}
// Copy from the source directly to the texture via the gpu, without a
// read-back to system memory. Source could be canvas or imageBitmap.
void TexImageByGPU(TexImageFunctionID,
WebGLTexture*,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
CanvasImageSource*,
const IntRect& source_sub_rectangle);
bool CanUseTexImageByGPU(GLenum format, GLenum type);
virtual WebGLImageConversion::PixelStoreParams GetPackPixelStoreParams();
virtual WebGLImageConversion::PixelStoreParams GetUnpackPixelStoreParams(
TexImageDimension);
......@@ -1697,19 +1684,22 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
const CanvasContextCreationAttributesCore&,
Platform::ContextType context_type,
bool* using_gpu_compositing);
void TexImageCanvasByGPU(TexImageFunctionID,
CanvasRenderingContextHost*,
GLenum,
GLuint,
GLint,
GLint,
const IntRect&);
void TexImageBitmapByGPU(ImageBitmap*,
GLenum,
GLuint,
GLint,
GLint,
const IntRect&);
// Copy from the source directly to the texture via the gpu, without
// a read-back to system memory. Source can be a texture-backed
// Image, or another canvas's WebGLRenderingContext.
void TexImageViaGPU(TexImageFunctionID,
WebGLTexture*,
GLenum,
GLint,
GLint,
GLint,
GLint,
AcceleratedStaticBitmapImage*,
WebGLRenderingContextBase*,
const IntRect& source_sub_rectangle,
bool premultiply_alpha,
bool flip_y);
bool CanUseTexImageViaGPU(GLenum format, GLenum type);
bool ValidateShaderType(const char* function_name, GLenum shader_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment