diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/graphics/gpu | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/graphics/gpu')
11 files changed, 235 insertions, 104 deletions
diff --git a/Source/WebCore/platform/graphics/gpu/BicubicShader.cpp b/Source/WebCore/platform/graphics/gpu/BicubicShader.cpp index 40c9843..f6f428d 100644 --- a/Source/WebCore/platform/graphics/gpu/BicubicShader.cpp +++ b/Source/WebCore/platform/graphics/gpu/BicubicShader.cpp @@ -55,11 +55,12 @@ PassOwnPtr<BicubicShader> BicubicShader::create(GraphicsContext3D* context) static const char* vertexShaderSource = "uniform mat3 matrix;\n" "uniform mat3 texMatrix;\n" - "attribute vec3 position;\n" + "attribute vec2 position;\n" "varying vec2 texCoord;\n" "void main() {\n" - " texCoord = (texMatrix * position).xy;\n" - " gl_Position = vec4(matrix * position, 1.0);\n" + " vec3 pos = vec3(position, 1.0);\n" + " texCoord = (texMatrix * pos).xy;\n" + " gl_Position = vec4(matrix * pos, 1.0);\n" "}\n"; static const char* fragmentShaderSource = "#ifdef GL_ES\n" @@ -127,7 +128,7 @@ void BicubicShader::use(const AffineTransform& transform, const AffineTransform& m_context->uniform1i(m_imageLocation, 0); m_context->uniform1f(m_alphaLocation, alpha); - m_context->vertexAttribPointer(m_positionLocation, 3, GraphicsContext3D::FLOAT, false, 0, 0); + m_context->vertexAttribPointer(m_positionLocation, 2, GraphicsContext3D::FLOAT, false, 0, 0); m_context->enableVertexAttribArray(m_positionLocation); } diff --git a/Source/WebCore/platform/graphics/gpu/ConvolutionShader.cpp b/Source/WebCore/platform/graphics/gpu/ConvolutionShader.cpp index f0b6bd9..b11d966 100644 --- a/Source/WebCore/platform/graphics/gpu/ConvolutionShader.cpp +++ b/Source/WebCore/platform/graphics/gpu/ConvolutionShader.cpp @@ -58,13 +58,14 @@ PassOwnPtr<ConvolutionShader> ConvolutionShader::create(GraphicsContext3D* conte "uniform mat3 matrix;\n" "uniform mat3 texMatrix;\n" "uniform vec2 imageIncrement;\n" - "attribute vec3 position;\n" + "attribute vec2 position;\n" "varying vec2 imageCoord;\n" "void main() {\n" + " vec3 pos = vec3(position, 1.0);\n" " // Offset image coords by half of kernel width, in image texels\n" - " gl_Position = vec4(matrix * position, 1.0);\n" + " gl_Position = vec4(matrix * pos, 1.0);\n" " float scale = (float(KERNEL_WIDTH) - 1.0) / 2.0;\n" - " imageCoord = (texMatrix * position).xy - vec2(scale, scale) * imageIncrement;\n" + " imageCoord = (texMatrix * pos).xy - vec2(scale, scale) * imageIncrement;\n" "}\n"; char vertexShaderSource[1024]; snprintf(vertexShaderSource, sizeof(vertexShaderSource), vertexShaderRaw, kernelWidth); @@ -115,7 +116,7 @@ void ConvolutionShader::use(const AffineTransform& transform, const AffineTransf kernelWidth = m_kernelWidth; m_context->uniform1fv(m_kernelLocation, const_cast<float*>(kernel), kernelWidth); - m_context->vertexAttribPointer(m_positionLocation, 3, GraphicsContext3D::FLOAT, false, 0, 0); + m_context->vertexAttribPointer(m_positionLocation, 2, GraphicsContext3D::FLOAT, false, 0, 0); m_context->enableVertexAttribArray(m_positionLocation); } diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp index 2a83fcf..8e293f7 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp @@ -144,112 +144,128 @@ void DrawingBuffer::resizeDepthStencil(int sampleCount) m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0); } -void DrawingBuffer::reset(const IntSize& newSize) +void DrawingBuffer::clearFramebuffer() { - m_size = newSize; + m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO ? m_multisampleFBO : m_fbo); + const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); + float clearDepth = 0; + int clearStencil = 0; + unsigned char depthMask = false; + unsigned int stencilMask = 0xffffffff; + unsigned char isScissorEnabled = false; + unsigned long clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; + if (attributes.depth) { + m_context->getFloatv(GraphicsContext3D::DEPTH_CLEAR_VALUE, &clearDepth); + m_context->clearDepth(1); + m_context->getBooleanv(GraphicsContext3D::DEPTH_WRITEMASK, &depthMask); + m_context->depthMask(true); + clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; + } + if (attributes.stencil) { + m_context->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &clearStencil); + m_context->clearStencil(0); + m_context->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<int*>(&stencilMask)); + m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xffffffff); + clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; + } + isScissorEnabled = m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST); + m_context->disable(GraphicsContext3D::SCISSOR_TEST); + + float clearColor[4]; + m_context->getFloatv(GraphicsContext3D::COLOR_CLEAR_VALUE, clearColor); + m_context->clearColor(0, 0, 0, 0); + m_context->clear(clearMask); + m_context->clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + + if (attributes.depth) { + m_context->clearDepth(clearDepth); + m_context->depthMask(depthMask); + } + if (attributes.stencil) { + m_context->clearStencil(clearStencil); + m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, stencilMask); + } + if (isScissorEnabled) + m_context->enable(GraphicsContext3D::SCISSOR_TEST); + else + m_context->disable(GraphicsContext3D::SCISSOR_TEST); +} +bool DrawingBuffer::reset(const IntSize& newSize) +{ if (!m_context) - return; - + return false; + m_context->makeContextCurrent(); - - const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - unsigned long internalColorFormat, colorFormat, internalRenderbufferFormat; - if (attributes.alpha) { - internalColorFormat = GraphicsContext3D::RGBA; - colorFormat = GraphicsContext3D::RGBA; - internalRenderbufferFormat = Extensions3D::RGBA8_OES; - } else { - internalColorFormat = GraphicsContext3D::RGB; - colorFormat = GraphicsContext3D::RGB; - internalRenderbufferFormat = Extensions3D::RGB8_OES; - } + int maxTextureSize = 0; + m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize); + if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) { + clear(); + return false; + } - // resize multisample FBO - if (multisample()) { - int maxSampleCount = 0; - - m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCount); - int sampleCount = std::min(8, maxSampleCount); + const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); + if (newSize != m_size) { + m_size = newSize; - m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); - m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height()); - m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); - resizeDepthStencil(sampleCount); - if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { - // Cleanup - clear(); - return; + unsigned long internalColorFormat, colorFormat, internalRenderbufferFormat; + if (attributes.alpha) { + internalColorFormat = GraphicsContext3D::RGBA; + colorFormat = GraphicsContext3D::RGBA; + internalRenderbufferFormat = Extensions3D::RGBA8_OES; + } else { + internalColorFormat = GraphicsContext3D::RGB; + colorFormat = GraphicsContext3D::RGB; + internalRenderbufferFormat = Extensions3D::RGB8_OES; } - } - // resize regular FBO - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); - m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer); - m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE); - m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0); - m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); - if (!multisample()) - resizeDepthStencil(0); - if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { - // Cleanup - clear(); - return; - } + // resize multisample FBO + if (multisample()) { + int maxSampleCount = 0; + + m_context->getIntegerv(Extensions3D::MAX_SAMPLES, &maxSampleCount); + int sampleCount = std::min(8, maxSampleCount); - if (multisample()) - m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); + m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); - if (!m_context->getExtensions()->supports("GL_CHROMIUM_resource_safe")) { - // Initialize renderbuffers (depth/stencil). - float clearDepth = 0; - int clearStencil = 0; - unsigned char depthMask = true; - unsigned int stencilMask = 0xffffffff; - unsigned char isScissorEnabled = false; - unsigned long clearMask = 0; - if (attributes.depth) { - m_context->getFloatv(GraphicsContext3D::DEPTH_CLEAR_VALUE, &clearDepth); - m_context->clearDepth(1); - m_context->getBooleanv(GraphicsContext3D::DEPTH_WRITEMASK, &depthMask); - m_context->depthMask(true); - clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; - } - if (attributes.stencil) { - m_context->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &clearStencil); - m_context->clearStencil(0); - m_context->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<int*>(&stencilMask)); - m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xffffffff); - clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; + m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); + m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height()); + m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer); + resizeDepthStencil(sampleCount); + if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { + // Cleanup + clear(); + return false; + } } - if (clearMask) { - isScissorEnabled = m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST); - m_context->disable(GraphicsContext3D::SCISSOR_TEST); - m_context->clear(clearMask); + // resize regular FBO + m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); - if (attributes.depth) { - m_context->clearDepth(clearDepth); - m_context->depthMask(depthMask); - } - if (attributes.stencil) { - m_context->clearStencil(clearStencil); - m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, stencilMask); - } - if (isScissorEnabled) - m_context->enable(GraphicsContext3D::SCISSOR_TEST); - else - m_context->disable(GraphicsContext3D::SCISSOR_TEST); + m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer); + + m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, internalColorFormat, m_size.width(), m_size.height(), 0, colorFormat, GraphicsContext3D::UNSIGNED_BYTE); + + m_context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_colorBuffer, 0); + m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0); + + if (!multisample()) + resizeDepthStencil(0); + if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { + // Cleanup + clear(); + return false; } } - m_context->flush(); - + clearFramebuffer(); + didReset(); + + return true; } void DrawingBuffer::commit(long x, long y, long width, long height) diff --git a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h index 606484e..caf3aa5 100644 --- a/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h +++ b/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h @@ -44,6 +44,7 @@ #if ENABLE(SKIA_GPU) class GrContext; +struct GrPlatformSurfaceDesc; #endif namespace WebCore { @@ -60,7 +61,10 @@ public: ~DrawingBuffer(); - void reset(const IntSize&); + void clearFramebuffer(); + + // Returns true if the buffer was successfully resized. + bool reset(const IntSize&); void bind(); IntSize size() const { return m_size; } Platform3DObject colorBuffer() const { return m_colorBuffer; } @@ -101,6 +105,7 @@ public: #if ENABLE(SKIA_GPU) void setGrContext(GrContext* ctx); + void getGrPlatformSurfaceDesc(GrPlatformSurfaceDesc*); #endif PassRefPtr<GraphicsContext3D> graphicsContext3D() const { return m_context; } diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp b/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp index 5b155a5..b228cbf 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp @@ -562,6 +562,108 @@ int numXRayCrossingsForCubic(const XRay& xRay, const FloatPoint cubic[4], bool& return numCrossings; } +/* + * Based on C code from the article + * "Testing the Convexity of a Polygon" + * by Peter Schorn and Frederick Fisher, + * (schorn@inf.ethz.ch, fred@kpc.com) + * in "Graphics Gems IV", Academic Press, 1994 + */ + +static inline int convexCompare(const FloatSize& delta) +{ + return (delta.width() > 0) ? -1 : /* x coord diff, second pt > first pt */ + (delta.width() < 0) ? 1 : /* x coord diff, second pt < first pt */ + (delta.height() > 0) ? -1 : /* x coord same, second pt > first pt */ + (delta.height() < 0) ? 1 : /* x coord same, second pt > first pt */ + 0; /* second pt equals first point */ +} + +static inline float convexCross(const FloatSize& p, const FloatSize& q) +{ + return p.width() * q.height() - p.height() * q.width(); +} + +static inline bool convexCheckTriple(const FloatSize& dcur, const FloatSize& dprev, int* curDir, int* dirChanges, int* angleSign) +{ + int thisDir = convexCompare(dcur); + if (thisDir == -*curDir) + ++*dirChanges; + *curDir = thisDir; + float cross = convexCross(dprev, dcur); + if (cross > 0) { + if (*angleSign == -1) + return false; + *angleSign = 1; + } else if (cross < 0) { + if (*angleSign == 1) + return false; + *angleSign = -1; + } + return true; +} + +bool isConvex(const FloatPoint* vertices, int nVertices) +{ + int dirChanges = 0, angleSign = 0; + FloatPoint second, third; + FloatSize dprev, dcur; + + /* Get different point, return if less than 3 diff points. */ + if (nVertices < 3) + return false; + int i = 1; + while (true) { + second = vertices[i++]; + dprev = second - vertices[0]; + if (dprev.width() || dprev.height()) + break; + /* Check if out of points. Check here to avoid slowing down cases + * without repeated points. + */ + if (i >= nVertices) + return false; + } + FloatPoint saveSecond = second; + int curDir = convexCompare(dprev); /* Find initial direction */ + while (i < nVertices) { + /* Get different point, break if no more points */ + third = vertices[i++]; + dcur = third - second; + if (!dcur.width() && !dcur.height()) + continue; + + /* Check current three points */ + if (!convexCheckTriple(dcur, dprev, &curDir, &dirChanges, &angleSign)) + return false; + second = third; /* Remember ptr to current point. */ + dprev = dcur; /* Remember current delta. */ + } + + /* Must check for direction changes from last vertex back to first */ + third = vertices[0]; /* Prepare for 'ConvexCheckTriple' */ + dcur = third - second; + if (convexCompare(dcur)) { + if (!convexCheckTriple(dcur, dprev, &curDir, &dirChanges, &angleSign)) + return false; + second = third; /* Remember ptr to current point. */ + dprev = dcur; /* Remember current delta. */ + } + + /* and check for direction changes back to second vertex */ + dcur = saveSecond - second; + if (!convexCheckTriple(dcur, dprev, &curDir, &dirChanges, &angleSign)) + return false; + + /* Decide on polygon type given accumulated status */ + if (dirChanges > 2) + return false; + + if (angleSign > 0 || angleSign < 0) + return true; + return false; +} + } // namespace LoopBlinnMathUtils } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.h b/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.h index b9d19c5..361d901 100644 --- a/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.h +++ b/Source/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.h @@ -101,6 +101,9 @@ bool xRayCrossesLine(const XRay& xRay, const FloatPoint lineEndpoints[2], bool& ambiguous); + +bool isConvex(const FloatPoint* vertices, int nVertices); + } // namespace LoopBlinnMathUtils } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/gpu/Shader.cpp b/Source/WebCore/platform/graphics/gpu/Shader.cpp index 1b9bfd5..13c5ebf 100644 --- a/Source/WebCore/platform/graphics/gpu/Shader.cpp +++ b/Source/WebCore/platform/graphics/gpu/Shader.cpp @@ -140,7 +140,7 @@ String Shader::generateVertex(Shader::VertexType vertexType, Shader::FillType fi case TwoDimensional: builder.append( "uniform mat3 matrix;\n" - "attribute vec3 position;\n"); + "attribute vec2 position;\n"); break; case LoopBlinnInterior: builder.append( @@ -167,7 +167,7 @@ String Shader::generateVertex(Shader::VertexType vertexType, Shader::FillType fi if (vertexType == TwoDimensional) { builder.append( - "gl_Position = vec4(matrix * position, 1.0);\n"); + "gl_Position = vec4(matrix * vec3(position, 1.0), 1.0);\n"); } else { builder.append( "gl_Position = worldViewProjection * vec4(position, 0.0, 1.0);\n"); @@ -179,7 +179,7 @@ String Shader::generateVertex(Shader::VertexType vertexType, Shader::FillType fi if (fillType == TextureFill) { builder.append( - "texCoord = texMatrix * position;\n"); + "texCoord = texMatrix * vec3(position, 1.0);\n"); } builder.append( diff --git a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp index 662d6a8..b7b94c4 100644 --- a/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp +++ b/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp @@ -346,10 +346,10 @@ void SharedGraphicsContext3D::enableStencil(bool enable) void SharedGraphicsContext3D::useQuadVertices() { if (!m_quadVertices) { - float vertices[] = { 0.0f, 0.0f, 1.0f, - 1.0f, 0.0f, 1.0f, - 0.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f }; + float vertices[] = { 0.0f, 0.0f, + 1.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 1.0f }; m_quadVertices = m_context->createBuffer(); m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_quadVertices); m_context->bufferData(GraphicsContext3D::ARRAY_BUFFER, sizeof(vertices), vertices, GraphicsContext3D::STATIC_DRAW); diff --git a/Source/WebCore/platform/graphics/gpu/SolidFillShader.cpp b/Source/WebCore/platform/graphics/gpu/SolidFillShader.cpp index 78381f0..0a6e084 100644 --- a/Source/WebCore/platform/graphics/gpu/SolidFillShader.cpp +++ b/Source/WebCore/platform/graphics/gpu/SolidFillShader.cpp @@ -69,7 +69,7 @@ void SolidFillShader::use(const AffineTransform& transform, const Color& color) affineTo3x3(transform, matrix); m_context->uniformMatrix3fv(m_matrixLocation, false /*transpose*/, matrix, 1 /*count*/); - m_context->vertexAttribPointer(m_positionLocation, 3, GraphicsContext3D::FLOAT, false, 0, 0); + m_context->vertexAttribPointer(m_positionLocation, 2, GraphicsContext3D::FLOAT, false, 0, 0); m_context->enableVertexAttribArray(m_positionLocation); } diff --git a/Source/WebCore/platform/graphics/gpu/TexShader.cpp b/Source/WebCore/platform/graphics/gpu/TexShader.cpp index 9eb5c16..ac141a5 100644 --- a/Source/WebCore/platform/graphics/gpu/TexShader.cpp +++ b/Source/WebCore/platform/graphics/gpu/TexShader.cpp @@ -72,7 +72,7 @@ void TexShader::use(const AffineTransform& transform, const AffineTransform& tex m_context->uniform1i(m_samplerLocation, sampler); m_context->uniform1f(m_alphaLocation, alpha); - m_context->vertexAttribPointer(m_positionLocation, 3, GraphicsContext3D::FLOAT, false, 0, 0); + m_context->vertexAttribPointer(m_positionLocation, 2, GraphicsContext3D::FLOAT, false, 0, 0); m_context->enableVertexAttribArray(m_positionLocation); diff --git a/Source/WebCore/platform/graphics/gpu/TilingData.cpp b/Source/WebCore/platform/graphics/gpu/TilingData.cpp index 1370543..2415ee4 100644 --- a/Source/WebCore/platform/graphics/gpu/TilingData.cpp +++ b/Source/WebCore/platform/graphics/gpu/TilingData.cpp @@ -44,6 +44,9 @@ namespace WebCore { static int computeNumTiles(int maxTextureSize, int totalSize, int borderTexels) { + if (maxTextureSize - 2 * borderTexels <= 0) + return totalSize > 0 && maxTextureSize >= totalSize ? 1 : 0; + int numTiles = max(1, 1 + (totalSize - 1 - 2 * borderTexels) / (maxTextureSize - 2 * borderTexels)); return totalSize > 0 ? numTiles : 0; } |