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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "modules/webgl/WebGLTexture.h" 42 #include "modules/webgl/WebGLTexture.h"
43 #include "modules/webgl/WebGLVertexArrayObjectBase.h" 43 #include "modules/webgl/WebGLVertexArrayObjectBase.h"
44 #include "platform/Timer.h" 44 #include "platform/Timer.h"
45 #include "platform/graphics/ImageBuffer.h" 45 #include "platform/graphics/ImageBuffer.h"
46 #include "platform/graphics/gpu/DrawingBuffer.h" 46 #include "platform/graphics/gpu/DrawingBuffer.h"
47 #include "platform/graphics/gpu/Extensions3DUtil.h" 47 #include "platform/graphics/gpu/Extensions3DUtil.h"
48 #include "platform/graphics/gpu/WebGLImageConversion.h" 48 #include "platform/graphics/gpu/WebGLImageConversion.h"
49 #include "public/platform/Platform.h" 49 #include "public/platform/Platform.h"
50 #include "public/platform/WebGraphicsContext3DProvider.h" 50 #include "public/platform/WebGraphicsContext3DProvider.h"
51 #include "third_party/khronos/GLES2/gl2.h" 51 #include "third_party/khronos/GLES2/gl2.h"
52 #include "wtf/CheckedNumeric.h"
52 #include "wtf/text/WTFString.h" 53 #include "wtf/text/WTFString.h"
53 #include <memory> 54 #include <memory>
54 #include <set> 55 #include <set>
55 56
56 namespace blink { 57 namespace blink {
57 class WebLayer; 58 class WebLayer;
58 } 59 }
59 60
60 namespace gpu { 61 namespace gpu {
61 namespace gles2 { 62 namespace gles2 {
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 GLenum type, 1018 GLenum type,
1018 Image*, 1019 Image*,
1019 WebGLImageConversion::ImageHtmlDomSource, 1020 WebGLImageConversion::ImageHtmlDomSource,
1020 bool flipY, 1021 bool flipY,
1021 bool premultiplyAlpha, 1022 bool premultiplyAlpha,
1022 const IntRect&, 1023 const IntRect&,
1023 GLsizei depth, 1024 GLsizei depth,
1024 GLint unpackImageHeight); 1025 GLint unpackImageHeight);
1025 template <typename T> 1026 template <typename T>
1026 bool validateTexImageSubRectangle(const char* functionName, 1027 bool validateTexImageSubRectangle(const char* functionName,
1028 TexImageFunctionID functionID,
1027 T* image, 1029 T* image,
1028 const IntRect& subRect, 1030 const IntRect& subRect,
1031 GLsizei depth,
1032 GLint unpackImageHeight,
1029 bool* selectingSubRectangle) { 1033 bool* selectingSubRectangle) {
1034 DCHECK(functionName);
1035 DCHECK(selectingSubRectangle);
1036 DCHECK(image);
1030 *selectingSubRectangle = image && 1037 *selectingSubRectangle = image &&
1031 !(subRect.x() == 0 && subRect.y() == 0 && 1038 !(subRect.x() == 0 && subRect.y() == 0 &&
1032 subRect.width() == image->width() && 1039 subRect.width() == image->width() &&
1033 subRect.height() == image->height()); 1040 subRect.height() == image->height());
1034 // If the source image rect selects anything except the entire 1041 // If the source image rect selects anything except the entire
1035 // contents of the image, assert that we're running WebGL 2.0 or 1042 // contents of the image, assert that we're running WebGL 2.0 or
1036 // higher, since this should never happen for WebGL 1.0 (even though 1043 // higher, since this should never happen for WebGL 1.0 (even though
1037 // the code could support it). If the image is null, that will be 1044 // the code could support it). If the image is null, that will be
1038 // signaled as an error later. 1045 // signaled as an error later.
1039 DCHECK(!*selectingSubRectangle || isWebGL2OrHigher()) 1046 DCHECK(!*selectingSubRectangle || isWebGL2OrHigher())
1040 << "subRect = (" << subRect.width() << " x " << subRect.height() 1047 << "subRect = (" << subRect.width() << " x " << subRect.height()
1041 << ") @ (" << subRect.x() << ", " << subRect.y() << "), image = (" 1048 << ") @ (" << subRect.x() << ", " << subRect.y() << "), image = ("
1042 << (image ? image->width() : -1) << " x " 1049 << (image ? image->width() : -1) << " x "
1043 << (image ? image->height() : -1) << ")"; 1050 << (image ? image->height() : -1) << ")";
1044 1051
1045 if (subRect.x() < 0 || subRect.y() < 0 || subRect.maxX() > image->width() || 1052 if (subRect.x() < 0 || subRect.y() < 0 || subRect.maxX() > image->width() ||
1046 subRect.maxY() > image->height() || subRect.width() < 0 || 1053 subRect.maxY() > image->height() || subRect.width() < 0 ||
1047 subRect.height() < 0) { 1054 subRect.height() < 0) {
1048 synthesizeGLError(GL_INVALID_OPERATION, functionName, 1055 synthesizeGLError(GL_INVALID_OPERATION, functionName,
1049 "source sub-rectangle specified via pixel unpack " 1056 "source sub-rectangle specified via pixel unpack "
1050 "parameters is invalid"); 1057 "parameters is invalid");
1051 return false; 1058 return false;
1052 } 1059 }
1060
1061 if (functionID == TexImage3D || functionID == TexSubImage3D) {
1062 DCHECK_GE(unpackImageHeight, 0);
1063
1064 // Verify that the image data can cover the required depth.
1065 WTF::CheckedNumeric<GLint> maxDepthSupported = 1;
1066 if (unpackImageHeight) {
1067 maxDepthSupported = subRect.height();
1068 maxDepthSupported /= unpackImageHeight;
1069 }
1070
1071 if (!maxDepthSupported.IsValid() ||
1072 maxDepthSupported.ValueOrDie() < depth) {
1073 synthesizeGLError(GL_INVALID_OPERATION, functionName,
1074 "Not enough data supplied to upload to a 3D texture "
1075 "with depth > 1");
1076 return false;
1077 }
1078 } else {
1079 DCHECK_EQ(depth, 1);
1080 DCHECK_EQ(unpackImageHeight, 0);
1081 }
1053 return true; 1082 return true;
1054 } 1083 }
1055 1084
1056 // Copy from the source directly to the texture via the gpu, without a 1085 // Copy from the source directly to the texture via the gpu, without a
1057 // read-back to system memory. Souce could be canvas or imageBitmap. 1086 // read-back to system memory. Souce could be canvas or imageBitmap.
1058 void texImageByGPU(TexImageByGPUType, 1087 void texImageByGPU(TexImageByGPUType,
1059 WebGLTexture*, 1088 WebGLTexture*,
1060 GLenum target, 1089 GLenum target,
1061 GLint level, 1090 GLint level,
1062 GLint internalformat, 1091 GLint internalformat,
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 GLint, 1533 GLint,
1505 GLint, 1534 GLint,
1506 GLint, 1535 GLint,
1507 GLenum, 1536 GLenum,
1508 GLenum, 1537 GLenum,
1509 GLsizei, 1538 GLsizei,
1510 GLint, 1539 GLint,
1511 GLint, 1540 GLint,
1512 GLint, 1541 GLint,
1513 ImageData*, 1542 ImageData*,
1514 const IntRect&); 1543 const IntRect&,
1544 GLint);
1515 void texImageHelperHTMLImageElement(TexImageFunctionID, 1545 void texImageHelperHTMLImageElement(TexImageFunctionID,
1516 GLenum, 1546 GLenum,
1517 GLint, 1547 GLint,
1518 GLint, 1548 GLint,
1519 GLenum, 1549 GLenum,
1520 GLenum, 1550 GLenum,
1521 GLint, 1551 GLint,
1522 GLint, 1552 GLint,
1523 GLint, 1553 GLint,
1524 HTMLImageElement*, 1554 HTMLImageElement*,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 context, 1628 context,
1599 context->is3d(), 1629 context->is3d(),
1600 context.is3d()); 1630 context.is3d());
1601 1631
1602 } // namespace blink 1632 } // namespace blink
1603 1633
1604 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( 1634 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(
1605 blink::WebGLRenderingContextBase::TextureUnitState); 1635 blink::WebGLRenderingContextBase::TextureUnitState);
1606 1636
1607 #endif // WebGLRenderingContextBase_h 1637 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698