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

Unified Diff: Source/core/platform/graphics/GraphicsContext3D.cpp

Issue 93873009: Moved GL enums from GraphicsContext3D to a more generic location. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Changed over to use the standard GL headers and enums. Also fixed some minor style issues. Created 7 years 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: Source/core/platform/graphics/GraphicsContext3D.cpp
diff --git a/Source/core/platform/graphics/GraphicsContext3D.cpp b/Source/core/platform/graphics/GraphicsContext3D.cpp
index d488df43ba8cd5a623a7418d1562135f1add2c66..d3569def95652351e67d35a75c61aead29d87d6f 100644
--- a/Source/core/platform/graphics/GraphicsContext3D.cpp
+++ b/Source/core/platform/graphics/GraphicsContext3D.cpp
@@ -430,7 +430,7 @@ DELEGATE_TO_WEBCONTEXT_1(linkProgram, Platform3DObject)
void GraphicsContext3D::pixelStorei(GC3Denum pname, GC3Dint param)
{
- if (pname == PACK_ALIGNMENT)
+ if (pname == GL_PACK_ALIGNMENT)
m_packAlignment = param;
m_impl->pixelStorei(pname, param);
}
@@ -535,7 +535,7 @@ PassRefPtr<Uint8ClampedArray> GraphicsContext3D::paintRenderingResultsToImageDat
RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(width * height * 4);
- m_impl->bindFramebuffer(FRAMEBUFFER, framebufferId);
+ m_impl->bindFramebuffer(GL_FRAMEBUFFER, framebufferId);
readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, AlphaDoNothing);
flipVertically(pixels->data(), width, height);
@@ -545,10 +545,10 @@ PassRefPtr<Uint8ClampedArray> GraphicsContext3D::paintRenderingResultsToImageDat
void GraphicsContext3D::readBackFramebuffer(unsigned char* pixels, int width, int height, ReadbackOrder readbackOrder, AlphaOp op)
{
if (m_packAlignment > 4)
- m_impl->pixelStorei(PACK_ALIGNMENT, 1);
- m_impl->readPixels(0, 0, width, height, RGBA, UNSIGNED_BYTE, pixels);
+ m_impl->pixelStorei(GL_PACK_ALIGNMENT, 1);
+ m_impl->readPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
if (m_packAlignment > 4)
- m_impl->pixelStorei(PACK_ALIGNMENT, m_packAlignment);
+ m_impl->pixelStorei(GL_PACK_ALIGNMENT, m_packAlignment);
size_t bufferSize = 4 * width * height;
@@ -609,19 +609,19 @@ bool GraphicsContext3D::computeFormatAndTypeParameters(GC3Denum format,
unsigned int* bytesPerComponent)
{
switch (format) {
- case GraphicsContext3D::ALPHA:
- case GraphicsContext3D::LUMINANCE:
- case GraphicsContext3D::DEPTH_COMPONENT:
- case GraphicsContext3D::DEPTH_STENCIL:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_STENCIL_OES:
*componentsPerPixel = 1;
break;
- case GraphicsContext3D::LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA:
*componentsPerPixel = 2;
break;
- case GraphicsContext3D::RGB:
+ case GL_RGB:
*componentsPerPixel = 3;
break;
- case GraphicsContext3D::RGBA:
+ case GL_RGBA:
case Extensions3D::BGRA_EXT: // GL_EXT_texture_format_BGRA8888
*componentsPerPixel = 4;
break;
@@ -629,26 +629,26 @@ bool GraphicsContext3D::computeFormatAndTypeParameters(GC3Denum format,
return false;
}
switch (type) {
- case GraphicsContext3D::UNSIGNED_BYTE:
+ case GL_UNSIGNED_BYTE:
*bytesPerComponent = sizeof(GC3Dubyte);
break;
- case GraphicsContext3D::UNSIGNED_SHORT:
+ case GL_UNSIGNED_SHORT:
*bytesPerComponent = sizeof(GC3Dushort);
break;
- case GraphicsContext3D::UNSIGNED_SHORT_5_6_5:
- case GraphicsContext3D::UNSIGNED_SHORT_4_4_4_4:
- case GraphicsContext3D::UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
*componentsPerPixel = 1;
*bytesPerComponent = sizeof(GC3Dushort);
break;
- case GraphicsContext3D::UNSIGNED_INT_24_8:
- case GraphicsContext3D::UNSIGNED_INT:
+ case GL_UNSIGNED_INT_24_8_OES:
+ case GL_UNSIGNED_INT:
*bytesPerComponent = sizeof(GC3Duint);
break;
- case GraphicsContext3D::FLOAT: // OES_texture_float
+ case GL_FLOAT: // OES_texture_float
*bytesPerComponent = sizeof(GC3Dfloat);
break;
- case GraphicsContext3D::HALF_FLOAT_OES: // OES_texture_half_float
+ case GL_HALF_FLOAT_OES: // OES_texture_half_float
*bytesPerComponent = sizeof(GC3Dhalffloat);
break;
default:
@@ -663,20 +663,20 @@ GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
ASSERT(imageSizeInBytes);
ASSERT(alignment == 1 || alignment == 2 || alignment == 4 || alignment == 8);
if (width < 0 || height < 0)
- return GraphicsContext3D::INVALID_VALUE;
+ return GL_INVALID_VALUE;
unsigned int bytesPerComponent, componentsPerPixel;
if (!computeFormatAndTypeParameters(format, type, &bytesPerComponent, &componentsPerPixel))
- return GraphicsContext3D::INVALID_ENUM;
+ return GL_INVALID_ENUM;
if (!width || !height) {
*imageSizeInBytes = 0;
if (paddingInBytes)
*paddingInBytes = 0;
- return GraphicsContext3D::NO_ERROR;
+ return GL_NO_ERROR;
}
CheckedInt<uint32_t> checkedValue(bytesPerComponent * componentsPerPixel);
checkedValue *= width;
if (!checkedValue.isValid())
- return GraphicsContext3D::INVALID_VALUE;
+ return GL_INVALID_VALUE;
unsigned int validRowSize = checkedValue.value();
unsigned int padding = 0;
unsigned int residual = validRowSize % alignment;
@@ -688,11 +688,11 @@ GC3Denum GraphicsContext3D::computeImageSizeInBytes(GC3Denum format, GC3Denum ty
checkedValue *= (height - 1);
checkedValue += validRowSize;
if (!checkedValue.isValid())
- return GraphicsContext3D::INVALID_VALUE;
+ return GL_INVALID_VALUE;
*imageSizeInBytes = checkedValue.value();
if (paddingInBytes)
*paddingInBytes = padding;
- return GraphicsContext3D::NO_ERROR;
+ return GL_NO_ERROR;
}
GraphicsContext3D::ImageExtractor::ImageExtractor(Image* image, ImageHtmlDomSource imageHtmlDomSource, bool premultiplyAlpha, bool ignoreGammaAndColorProfile)
@@ -763,22 +763,22 @@ bool GraphicsContext3D::ImageExtractor::extractImage(bool premultiplyAlpha, bool
unsigned GraphicsContext3D::getClearBitsByFormat(GC3Denum format)
{
switch (format) {
- case GraphicsContext3D::ALPHA:
- case GraphicsContext3D::LUMINANCE:
- case GraphicsContext3D::LUMINANCE_ALPHA:
- case GraphicsContext3D::RGB:
- case GraphicsContext3D::RGB565:
- case GraphicsContext3D::RGBA:
- case GraphicsContext3D::RGBA4:
- case GraphicsContext3D::RGB5_A1:
- return GraphicsContext3D::COLOR_BUFFER_BIT;
- case GraphicsContext3D::DEPTH_COMPONENT16:
- case GraphicsContext3D::DEPTH_COMPONENT:
- return GraphicsContext3D::DEPTH_BUFFER_BIT;
- case GraphicsContext3D::STENCIL_INDEX8:
- return GraphicsContext3D::STENCIL_BUFFER_BIT;
- case GraphicsContext3D::DEPTH_STENCIL:
- return GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGB:
+ case GL_RGB565:
+ case GL_RGBA:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ return GL_COLOR_BUFFER_BIT;
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT:
+ return GL_DEPTH_BUFFER_BIT;
+ case GL_STENCIL_INDEX8:
+ return GL_STENCIL_BUFFER_BIT;
+ case GL_DEPTH_STENCIL_OES:
+ return GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
default:
return 0;
}
@@ -787,25 +787,25 @@ unsigned GraphicsContext3D::getClearBitsByFormat(GC3Denum format)
unsigned GraphicsContext3D::getChannelBitsByFormat(GC3Denum format)
{
switch (format) {
- case GraphicsContext3D::ALPHA:
+ case GL_ALPHA:
return ChannelAlpha;
- case GraphicsContext3D::LUMINANCE:
+ case GL_LUMINANCE:
return ChannelRGB;
- case GraphicsContext3D::LUMINANCE_ALPHA:
+ case GL_LUMINANCE_ALPHA:
return ChannelRGBA;
- case GraphicsContext3D::RGB:
- case GraphicsContext3D::RGB565:
+ case GL_RGB:
+ case GL_RGB565:
return ChannelRGB;
- case GraphicsContext3D::RGBA:
- case GraphicsContext3D::RGBA4:
- case GraphicsContext3D::RGB5_A1:
+ case GL_RGBA:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
return ChannelRGBA;
- case GraphicsContext3D::DEPTH_COMPONENT16:
- case GraphicsContext3D::DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT:
return ChannelDepth;
- case GraphicsContext3D::STENCIL_INDEX8:
+ case GL_STENCIL_INDEX8:
return ChannelStencil;
- case GraphicsContext3D::DEPTH_STENCIL:
+ case GL_DEPTH_STENCIL_OES:
return ChannelDepth | ChannelStencil;
default:
return 0;
@@ -840,7 +840,7 @@ void GraphicsContext3D::paintFramebufferToCanvas(int framebuffer, int width, int
SkAutoLockPixels bitmapLock(*readbackBitmap);
pixels = static_cast<unsigned char*>(readbackBitmap->getPixels());
- m_impl->bindFramebuffer(FRAMEBUFFER, framebuffer);
+ m_impl->bindFramebuffer(GL_FRAMEBUFFER, framebuffer);
readBackFramebuffer(pixels, width, height, ReadbackSkia, premultiplyAlpha ? AlphaDoPremultiply : AlphaDoNothing);
flipVertically(pixels, width, height);
@@ -885,7 +885,7 @@ void GraphicsContext3D::initializeExtensions()
if (!success)
return;
- String extensionsString = m_impl->getString(GraphicsContext3D::EXTENSIONS);
+ String extensionsString = m_impl->getString(GL_EXTENSIONS);
splitStringHelper(extensionsString, m_enabledExtensions);
String requestableExtensionsString = m_impl->getRequestableExtensionsCHROMIUM();

Powered by Google App Engine
This is Rietveld 408576698