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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 m_drawCache.use_premultiplied_alpha = quad->premultiplied_alpha; | 1078 m_drawCache.use_premultiplied_alpha = quad->premultiplied_alpha; |
1079 m_drawCache.needs_blending = quad->ShouldDrawWithBlending(); | 1079 m_drawCache.needs_blending = quad->ShouldDrawWithBlending(); |
1080 | 1080 |
1081 m_drawCache.uv_xform_location = binding.texTransformLocation; | 1081 m_drawCache.uv_xform_location = binding.texTransformLocation; |
1082 m_drawCache.vertex_opacity_location = binding.vertexOpacityLocation; | 1082 m_drawCache.vertex_opacity_location = binding.vertexOpacityLocation; |
1083 m_drawCache.matrix_location = binding.matrixLocation; | 1083 m_drawCache.matrix_location = binding.matrixLocation; |
1084 m_drawCache.sampler_location = binding.samplerLocation; | 1084 m_drawCache.sampler_location = binding.samplerLocation; |
1085 } | 1085 } |
1086 | 1086 |
1087 // Generate the uv-transform | 1087 // Generate the uv-transform |
1088 const gfx::RectF& uvRect = quad->uv_rect; | 1088 const gfx::PointF& uv0 = quad->uv_top_left; |
1089 Float4 uv = {uvRect.x(), uvRect.y(), uvRect.width(), uvRect.height()}; | 1089 const gfx::PointF& uv1 = quad->uv_bottom_right; |
| 1090 Float4 uv = {uv0.x(), uv0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y()}; |
1090 m_drawCache.uv_xform_data.push_back(uv); | 1091 m_drawCache.uv_xform_data.push_back(uv); |
1091 | 1092 |
1092 // Generate the vertex opacity | 1093 // Generate the vertex opacity |
1093 const float opacity = quad->opacity(); | 1094 const float opacity = quad->opacity(); |
1094 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity)
; | 1095 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity)
; |
1095 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity)
; | 1096 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[1] * opacity)
; |
1096 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity)
; | 1097 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[2] * opacity)
; |
1097 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity)
; | 1098 m_drawCache.vertex_opacity_data.push_back(quad->vertex_opacity[3] * opacity)
; |
1098 | 1099 |
1099 // Generate the transform matrix | 1100 // Generate the transform matrix |
1100 gfx::Transform quadRectMatrix; | 1101 gfx::Transform quadRectMatrix; |
1101 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); | 1102 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); |
1102 quadRectMatrix = frame.projectionMatrix * quadRectMatrix; | 1103 quadRectMatrix = frame.projectionMatrix * quadRectMatrix; |
1103 | 1104 |
1104 Float16 m; | 1105 Float16 m; |
1105 quadRectMatrix.matrix().asColMajorf(m.data); | 1106 quadRectMatrix.matrix().asColMajorf(m.data); |
1106 m_drawCache.matrix_data.push_back(m); | 1107 m_drawCache.matrix_data.push_back(m); |
1107 } | 1108 } |
1108 | 1109 |
1109 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua
d* quad) | 1110 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua
d* quad) |
1110 { | 1111 { |
1111 TexTransformTextureProgramBinding binding; | 1112 TexTransformTextureProgramBinding binding; |
1112 if (quad->flipped) | 1113 if (quad->flipped) |
1113 binding.set(textureProgramFlip(), context()); | 1114 binding.set(textureProgramFlip(), context()); |
1114 else | 1115 else |
1115 binding.set(textureProgram(), context()); | 1116 binding.set(textureProgram(), context()); |
1116 setUseProgram(binding.programId); | 1117 setUseProgram(binding.programId); |
1117 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); | 1118 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); |
1118 const gfx::RectF& uvRect = quad->uv_rect; | 1119 const gfx::PointF& uv0 = quad->uv_top_left; |
1119 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x()
, uvRect.y(), uvRect.width(), uvRect.height())); | 1120 const gfx::PointF& uv1 = quad->uv_bottom_right; |
| 1121 GLC(context(), context()->uniform4f(binding.texTransformLocation, uv0.x(), u
v0.y(), uv1.x() - uv0.x(), uv1.y() - uv0.y())); |
1120 | 1122 |
1121 GLC(context(), context()->uniform1fv(binding.vertexOpacityLocation, 4, quad-
>vertex_opacity)); | 1123 GLC(context(), context()->uniform1fv(binding.vertexOpacityLocation, 4, quad-
>vertex_opacity)); |
1122 | 1124 |
1123 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad-
>resource_id, GL_TEXTURE_2D, GL_LINEAR); | 1125 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad-
>resource_id, GL_TEXTURE_2D, GL_LINEAR); |
1124 | 1126 |
1125 if (!quad->premultiplied_alpha) { | 1127 if (!quad->premultiplied_alpha) { |
1126 // As it turns out, the premultiplied alpha blending function (ONE, ONE_
MINUS_SRC_ALPHA) | 1128 // As it turns out, the premultiplied alpha blending function (ONE, ONE_
MINUS_SRC_ALPHA) |
1127 // will never cause the alpha channel to be set to anything less than 1.
0 if it is | 1129 // will never cause the alpha channel to be set to anything less than 1.
0 if it is |
1128 // initialized to that value! Therefore, premultipliedAlpha being false
is the first | 1130 // initialized to that value! Therefore, premultipliedAlpha being false
is the first |
1129 // situation we can generally see an alpha channel less than 1.0 coming
out of the | 1131 // situation we can generally see an alpha channel less than 1.0 coming
out of the |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 | 1797 |
1796 releaseRenderPassTextures(); | 1798 releaseRenderPassTextures(); |
1797 } | 1799 } |
1798 | 1800 |
1799 bool GLRenderer::isContextLost() | 1801 bool GLRenderer::isContextLost() |
1800 { | 1802 { |
1801 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1803 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1802 } | 1804 } |
1803 | 1805 |
1804 } // namespace cc | 1806 } // namespace cc |
OLD | NEW |