OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); | 753 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); |
754 else | 754 else |
755 tileUniformLocation(tileProgramOpaque(), uniforms); | 755 tileUniformLocation(tileProgramOpaque(), uniforms); |
756 } | 756 } |
757 } | 757 } |
758 | 758 |
759 GLC(context(), context()->useProgram(uniforms.program)); | 759 GLC(context(), context()->useProgram(uniforms.program)); |
760 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); | 760 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); |
761 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad
->resourceId()); | 761 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad
->resourceId()); |
762 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur
eId())); | 762 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur
eId())); |
763 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, quad->textureFilter())); | |
764 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, quad->textureFilter())); | |
765 | 763 |
766 bool useAA = !clipped && quad->isAntialiased(); | 764 bool useAA = !clipped && quad->isAntialiased(); |
767 if (useAA) { | 765 if (useAA) { |
768 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound
ingBox())); | 766 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound
ingBox())); |
769 deviceLayerBounds.inflateAntiAliasingDistance(); | 767 deviceLayerBounds.inflateAntiAliasingDistance(); |
770 | 768 |
771 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); | 769 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); |
772 deviceLayerEdges.inflateAntiAliasingDistance(); | 770 deviceLayerEdges.inflateAntiAliasingDistance(); |
773 | 771 |
774 float edge[24]; | 772 float edge[24]; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 else | 961 else |
964 binding.set(textureProgram()); | 962 binding.set(textureProgram()); |
965 GLC(context(), context()->useProgram(binding.programId)); | 963 GLC(context(), context()->useProgram(binding.programId)); |
966 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); | 964 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); |
967 const gfx::RectF& uvRect = quad->uvRect(); | 965 const gfx::RectF& uvRect = quad->uvRect(); |
968 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x()
, uvRect.y(), uvRect.width(), uvRect.height())); | 966 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x()
, uvRect.y(), uvRect.width(), uvRect.height())); |
969 | 967 |
970 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad
->resourceId()); | 968 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad
->resourceId()); |
971 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur
eId())); | 969 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur
eId())); |
972 | 970 |
973 // FIXME: setting the texture parameters every time is redundant. Move this
code somewhere | |
974 // where it will only happen once per texture. | |
975 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, GL_LINEAR)); | |
976 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, GL_LINEAR)); | |
977 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL
_CLAMP_TO_EDGE)); | |
978 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL
_CLAMP_TO_EDGE)); | |
979 | |
980 if (!quad->premultipliedAlpha()) { | 971 if (!quad->premultipliedAlpha()) { |
981 // As it turns out, the premultiplied alpha blending function (ONE, ONE_
MINUS_SRC_ALPHA) | 972 // As it turns out, the premultiplied alpha blending function (ONE, ONE_
MINUS_SRC_ALPHA) |
982 // will never cause the alpha channel to be set to anything less than 1.
0 if it is | 973 // will never cause the alpha channel to be set to anything less than 1.
0 if it is |
983 // initialized to that value! Therefore, premultipliedAlpha being false
is the first | 974 // initialized to that value! Therefore, premultipliedAlpha being false
is the first |
984 // situation we can generally see an alpha channel less than 1.0 coming
out of the | 975 // situation we can generally see an alpha channel less than 1.0 coming
out of the |
985 // compositor. This is causing platform differences in some layout tests
(see | 976 // compositor. This is causing platform differences in some layout tests
(see |
986 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation,
use a separate | 977 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation,
use a separate |
987 // blend function for the alpha channel to avoid modifying it. Don't use
colorMask for this | 978 // blend function for the alpha channel to avoid modifying it. Don't use
colorMask for this |
988 // as it has performance implications on some platforms. | 979 // as it has performance implications on some platforms. |
989 GLC(context(), context()->blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_S
RC_ALPHA, GL_ZERO, GL_ONE)); | 980 GLC(context(), context()->blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_S
RC_ALPHA, GL_ZERO, GL_ONE)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 GLC(m_context, m_context->uniformMatrix4fv(matrixLocation, 1, false, &glMatr
ix[0])); | 1072 GLC(m_context, m_context->uniformMatrix4fv(matrixLocation, 1, false, &glMatr
ix[0])); |
1082 | 1073 |
1083 GLC(m_context, m_context->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0
)); | 1074 GLC(m_context, m_context->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0
)); |
1084 } | 1075 } |
1085 | 1076 |
1086 void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int texture
Id, const gfx::Rect& rect, const WebTransformationMatrix& drawMatrix) | 1077 void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int texture
Id, const gfx::Rect& rect, const WebTransformationMatrix& drawMatrix) |
1087 { | 1078 { |
1088 const RenderPassProgram* program = renderPassProgram(); | 1079 const RenderPassProgram* program = renderPassProgram(); |
1089 | 1080 |
1090 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, textureId)); | 1081 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, textureId)); |
1091 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, GL_LINEAR)); | |
1092 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, GL_LINEAR)); | |
1093 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL
_CLAMP_TO_EDGE)); | |
1094 GLC(context(), context()->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL
_CLAMP_TO_EDGE)); | |
1095 | 1082 |
1096 GLC(context(), context()->useProgram(program->program())); | 1083 GLC(context(), context()->useProgram(program->program())); |
1097 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio
n(), 0)); | 1084 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio
n(), 0)); |
1098 setShaderOpacity(1, program->fragmentShader().alphaLocation()); | 1085 setShaderOpacity(1, program->fragmentShader().alphaLocation()); |
1099 drawQuadGeometry(frame, drawMatrix, rect, program->vertexShader().matrixLoca
tion()); | 1086 drawQuadGeometry(frame, drawMatrix, rect, program->vertexShader().matrixLoca
tion()); |
1100 } | 1087 } |
1101 | 1088 |
1102 void GLRenderer::finish() | 1089 void GLRenderer::finish() |
1103 { | 1090 { |
1104 TRACE_EVENT0("cc", "GLRenderer::finish"); | 1091 TRACE_EVENT0("cc", "GLRenderer::finish"); |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 | 1590 |
1604 releaseRenderPassTextures(); | 1591 releaseRenderPassTextures(); |
1605 } | 1592 } |
1606 | 1593 |
1607 bool GLRenderer::isContextLost() | 1594 bool GLRenderer::isContextLost() |
1608 { | 1595 { |
1609 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1596 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1610 } | 1597 } |
1611 | 1598 |
1612 } // namespace cc | 1599 } // namespace cc |
OLD | NEW |