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 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 // Check to see if we have anything to draw. | 978 // Check to see if we have anything to draw. |
979 if (m_drawCache.program_id == 0) | 979 if (m_drawCache.program_id == 0) |
980 return; | 980 return; |
981 | 981 |
982 // Set the correct blending mode. | 982 // Set the correct blending mode. |
983 setBlendEnabled(m_drawCache.needs_blending); | 983 setBlendEnabled(m_drawCache.needs_blending); |
984 | 984 |
985 // Bind the program to the GL state. | 985 // Bind the program to the GL state. |
986 setUseProgram(m_drawCache.program_id); | 986 setUseProgram(m_drawCache.program_id); |
987 | 987 |
| 988 // Bind the correct texture sampler location. |
| 989 GLC(context(), context()->uniform1i(m_drawCache.sampler_location, 0)); |
| 990 |
988 // Assume the current active textures is 0. | 991 // Assume the current active textures is 0. |
989 ResourceProvider::ScopedReadLockGL lockedQuad(m_resourceProvider, m_drawCach
e.resource_id); | 992 ResourceProvider::ScopedReadLockGL lockedQuad(m_resourceProvider, m_drawCach
e.resource_id); |
990 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, lockedQuad.textureId())
); | 993 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, lockedQuad.textureId())
); |
991 | 994 |
992 // set up premultiplied alpha. | 995 // set up premultiplied alpha. |
993 if (!m_drawCache.use_premultiplied_alpha) { | 996 if (!m_drawCache.use_premultiplied_alpha) { |
994 // As it turns out, the premultiplied alpha blending function (ONE, ONE_MI
NUS_SRC_ALPHA) | 997 // As it turns out, the premultiplied alpha blending function (ONE, ONE_MI
NUS_SRC_ALPHA) |
995 // will never cause the alpha channel to be set to anything less than 1.
0 if it is | 998 // will never cause the alpha channel to be set to anything less than 1.
0 if it is |
996 // initialized to that value! Therefore, premultipliedAlpha being false
is the first | 999 // initialized to that value! Therefore, premultipliedAlpha being false
is the first |
997 // situation we can generally see an alpha channel less than 1.0 coming
out of the | 1000 // situation we can generally see an alpha channel less than 1.0 coming
out of the |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 flushTextureQuadCache(); | 1048 flushTextureQuadCache(); |
1046 m_drawCache.program_id = binding.programId; | 1049 m_drawCache.program_id = binding.programId; |
1047 m_drawCache.resource_id = resourceID; | 1050 m_drawCache.resource_id = resourceID; |
1048 m_drawCache.alpha = quad->opacity(); | 1051 m_drawCache.alpha = quad->opacity(); |
1049 m_drawCache.use_premultiplied_alpha = quad->premultiplied_alpha; | 1052 m_drawCache.use_premultiplied_alpha = quad->premultiplied_alpha; |
1050 m_drawCache.needs_blending = quad->ShouldDrawWithBlending(); | 1053 m_drawCache.needs_blending = quad->ShouldDrawWithBlending(); |
1051 | 1054 |
1052 m_drawCache.alpha_location = binding.alphaLocation; | 1055 m_drawCache.alpha_location = binding.alphaLocation; |
1053 m_drawCache.uv_xform_location = binding.texTransformLocation; | 1056 m_drawCache.uv_xform_location = binding.texTransformLocation; |
1054 m_drawCache.matrix_location = binding.matrixLocation; | 1057 m_drawCache.matrix_location = binding.matrixLocation; |
| 1058 m_drawCache.sampler_location = binding.samplerLocation; |
1055 } | 1059 } |
1056 | 1060 |
1057 // Generate the uv-transform | 1061 // Generate the uv-transform |
1058 const gfx::RectF& uvRect = quad->uv_rect; | 1062 const gfx::RectF& uvRect = quad->uv_rect; |
1059 Float4 uv = {uvRect.x(), uvRect.y(), uvRect.width(), uvRect.height()}; | 1063 Float4 uv = {uvRect.x(), uvRect.y(), uvRect.width(), uvRect.height()}; |
1060 m_drawCache.uv_xform_data.push_back(uv); | 1064 m_drawCache.uv_xform_data.push_back(uv); |
1061 | 1065 |
1062 // Generate the transform matrix | 1066 // Generate the transform matrix |
1063 gfx::Transform quadRectMatrix; | 1067 gfx::Transform quadRectMatrix; |
1064 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); | 1068 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 return m_tileProgramSwizzleAA.get(); | 1643 return m_tileProgramSwizzleAA.get(); |
1640 } | 1644 } |
1641 | 1645 |
1642 const GLRenderer::TextureProgram* GLRenderer::textureProgram() | 1646 const GLRenderer::TextureProgram* GLRenderer::textureProgram() |
1643 { | 1647 { |
1644 if (!m_textureProgram) | 1648 if (!m_textureProgram) |
1645 m_textureProgram = make_scoped_ptr(new TextureProgram(m_context)); | 1649 m_textureProgram = make_scoped_ptr(new TextureProgram(m_context)); |
1646 if (!m_textureProgram->initialized()) { | 1650 if (!m_textureProgram->initialized()) { |
1647 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 1651 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
1648 m_textureProgram->initialize(m_context, m_isUsingBindUniform); | 1652 m_textureProgram->initialize(m_context, m_isUsingBindUniform); |
1649 GLC(context(), context()->uniform1i(m_textureProgram.get()->fragmentShad
er().samplerLocation(), 0)); | |
1650 } | 1653 } |
1651 return m_textureProgram.get(); | 1654 return m_textureProgram.get(); |
1652 } | 1655 } |
1653 | 1656 |
1654 const GLRenderer::TextureProgramFlip* GLRenderer::textureProgramFlip() | 1657 const GLRenderer::TextureProgramFlip* GLRenderer::textureProgramFlip() |
1655 { | 1658 { |
1656 if (!m_textureProgramFlip) | 1659 if (!m_textureProgramFlip) |
1657 m_textureProgramFlip = make_scoped_ptr(new TextureProgramFlip(m_context)
); | 1660 m_textureProgramFlip = make_scoped_ptr(new TextureProgramFlip(m_context)
); |
1658 if (!m_textureProgramFlip->initialized()) { | 1661 if (!m_textureProgramFlip->initialized()) { |
1659 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); | 1662 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); |
1660 m_textureProgramFlip->initialize(m_context, m_isUsingBindUniform); | 1663 m_textureProgramFlip->initialize(m_context, m_isUsingBindUniform); |
1661 GLC(context(), context()->uniform1i(m_textureProgramFlip.get()->fragment
Shader().samplerLocation(), 0)); | |
1662 } | 1664 } |
1663 return m_textureProgramFlip.get(); | 1665 return m_textureProgramFlip.get(); |
1664 } | 1666 } |
1665 | 1667 |
1666 const GLRenderer::TextureIOSurfaceProgram* GLRenderer::textureIOSurfaceProgram() | 1668 const GLRenderer::TextureIOSurfaceProgram* GLRenderer::textureIOSurfaceProgram() |
1667 { | 1669 { |
1668 if (!m_textureIOSurfaceProgram) | 1670 if (!m_textureIOSurfaceProgram) |
1669 m_textureIOSurfaceProgram = make_scoped_ptr(new TextureIOSurfaceProgram(
m_context)); | 1671 m_textureIOSurfaceProgram = make_scoped_ptr(new TextureIOSurfaceProgram(
m_context)); |
1670 if (!m_textureIOSurfaceProgram->initialized()) { | 1672 if (!m_textureIOSurfaceProgram->initialized()) { |
1671 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); | 1673 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 | 1748 |
1747 releaseRenderPassTextures(); | 1749 releaseRenderPassTextures(); |
1748 } | 1750 } |
1749 | 1751 |
1750 bool GLRenderer::isContextLost() | 1752 bool GLRenderer::isContextLost() |
1751 { | 1753 { |
1752 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1754 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1753 } | 1755 } |
1754 | 1756 |
1755 } // namespace cc | 1757 } // namespace cc |
OLD | NEW |