Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h

Issue 2500433003: support 3d texture sub-source uploads from ImageData (Closed)
Patch Set: address comment + rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
index b459f9e053d2ce628929f475584f5017ba8f964f..d50f46b6dd73757a7ae7a303e29af45b62a0f792 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h
@@ -49,6 +49,7 @@
#include "public/platform/Platform.h"
#include "public/platform/WebGraphicsContext3DProvider.h"
#include "third_party/khronos/GLES2/gl2.h"
+#include "wtf/CheckedNumeric.h"
#include "wtf/text/WTFString.h"
#include <memory>
#include <set>
@@ -1024,9 +1025,15 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
GLint unpackImageHeight);
template <typename T>
bool validateTexImageSubRectangle(const char* functionName,
+ TexImageFunctionID functionID,
T* image,
const IntRect& subRect,
+ GLsizei depth,
+ GLint unpackImageHeight,
bool* selectingSubRectangle) {
+ DCHECK(functionName);
+ DCHECK(selectingSubRectangle);
+ DCHECK(image);
*selectingSubRectangle = image &&
!(subRect.x() == 0 && subRect.y() == 0 &&
subRect.width() == image->width() &&
@@ -1050,6 +1057,28 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
"parameters is invalid");
return false;
}
+
+ if (functionID == TexImage3D || functionID == TexSubImage3D) {
+ DCHECK_GE(unpackImageHeight, 0);
+
+ // Verify that the image data can cover the required depth.
+ WTF::CheckedNumeric<GLint> maxDepthSupported = 1;
+ if (unpackImageHeight) {
+ maxDepthSupported = subRect.height();
+ maxDepthSupported /= unpackImageHeight;
+ }
+
+ if (!maxDepthSupported.IsValid() ||
+ maxDepthSupported.ValueOrDie() < depth) {
+ synthesizeGLError(GL_INVALID_OPERATION, functionName,
+ "Not enough data supplied to upload to a 3D texture "
+ "with depth > 1");
+ return false;
+ }
+ } else {
+ DCHECK_EQ(depth, 1);
+ DCHECK_EQ(unpackImageHeight, 0);
+ }
return true;
}
@@ -1511,7 +1540,8 @@ class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext,
GLint,
GLint,
ImageData*,
- const IntRect&);
+ const IntRect&,
+ GLint);
void texImageHelperHTMLImageElement(TexImageFunctionID,
GLenum,
GLint,

Powered by Google App Engine
This is Rietveld 408576698