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