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