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/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2103 // Set the correct blending mode. | 2103 // Set the correct blending mode. |
2104 SetBlendEnabled(draw_cache_.needs_blending); | 2104 SetBlendEnabled(draw_cache_.needs_blending); |
2105 | 2105 |
2106 // Bind the program to the GL state. | 2106 // Bind the program to the GL state. |
2107 SetUseProgram(draw_cache_.program_id); | 2107 SetUseProgram(draw_cache_.program_id); |
2108 | 2108 |
2109 // Bind the correct texture sampler location. | 2109 // Bind the correct texture sampler location. |
2110 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); | 2110 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); |
2111 | 2111 |
2112 // Assume the current active textures is 0. | 2112 // Assume the current active textures is 0. |
2113 ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_, | 2113 ResourceProvider::ScopedSamplerGL locked_quad(resource_provider_, |
2114 draw_cache_.resource_id); | 2114 draw_cache_.resource_id, |
2115 draw_cache_.nearest_neighbor); | |
piman
2014/10/28 05:09:50
You need an enum here (GL_LINEAR or GL_NEAREST), n
jackhou1
2014/10/29 00:12:25
Done.
| |
2115 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); | 2116 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); |
2116 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id())); | 2117 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id())); |
2117 | 2118 |
2118 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed); | 2119 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed); |
2119 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float), | 2120 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float), |
2120 struct_is_densely_packed); | 2121 struct_is_densely_packed); |
2121 | 2122 |
2123 //printf("GLRenderer::FlushTextureQuadCache %d %d\n", draw_cache_.nearest_neig hbor, draw_cache_.resource_id); | |
2124 | |
2122 // Upload the tranforms for both points and uvs. | 2125 // Upload the tranforms for both points and uvs. |
2123 GLC(gl_, | 2126 GLC(gl_, |
2124 gl_->UniformMatrix4fv( | 2127 gl_->UniformMatrix4fv( |
2125 static_cast<int>(draw_cache_.matrix_location), | 2128 static_cast<int>(draw_cache_.matrix_location), |
2126 static_cast<int>(draw_cache_.matrix_data.size()), | 2129 static_cast<int>(draw_cache_.matrix_data.size()), |
2127 false, | 2130 false, |
2128 reinterpret_cast<float*>(&draw_cache_.matrix_data.front()))); | 2131 reinterpret_cast<float*>(&draw_cache_.matrix_data.front()))); |
2129 GLC(gl_, | 2132 GLC(gl_, |
2130 gl_->Uniform4fv( | 2133 gl_->Uniform4fv( |
2131 static_cast<int>(draw_cache_.uv_xform_location), | 2134 static_cast<int>(draw_cache_.uv_xform_location), |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2179 if (quad->background_color == SK_ColorTRANSPARENT) { | 2182 if (quad->background_color == SK_ColorTRANSPARENT) { |
2180 binding.Set(GetNonPremultipliedTextureProgram(tex_coord_precision)); | 2183 binding.Set(GetNonPremultipliedTextureProgram(tex_coord_precision)); |
2181 } else { | 2184 } else { |
2182 binding.Set( | 2185 binding.Set( |
2183 GetNonPremultipliedTextureBackgroundProgram(tex_coord_precision)); | 2186 GetNonPremultipliedTextureBackgroundProgram(tex_coord_precision)); |
2184 } | 2187 } |
2185 } | 2188 } |
2186 | 2189 |
2187 int resource_id = quad->resource_id; | 2190 int resource_id = quad->resource_id; |
2188 | 2191 |
2192 //printf("GLRenderer::EnqueueTextureQuad %d %d\n", quad->nearest_neighbor, res ource_id); | |
2193 | |
2189 if (draw_cache_.program_id != binding.program_id || | 2194 if (draw_cache_.program_id != binding.program_id || |
2190 draw_cache_.resource_id != resource_id || | 2195 draw_cache_.resource_id != resource_id || |
2191 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || | 2196 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || |
2197 draw_cache_.nearest_neighbor != quad->nearest_neighbor || | |
2192 draw_cache_.background_color != quad->background_color || | 2198 draw_cache_.background_color != quad->background_color || |
2193 draw_cache_.matrix_data.size() >= 8) { | 2199 draw_cache_.matrix_data.size() >= 8) { |
2194 FlushTextureQuadCache(); | 2200 FlushTextureQuadCache(); |
2195 draw_cache_.program_id = binding.program_id; | 2201 draw_cache_.program_id = binding.program_id; |
2196 draw_cache_.resource_id = resource_id; | 2202 draw_cache_.resource_id = resource_id; |
2197 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); | 2203 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); |
2204 draw_cache_.nearest_neighbor = quad->nearest_neighbor; | |
2198 draw_cache_.background_color = quad->background_color; | 2205 draw_cache_.background_color = quad->background_color; |
2199 | 2206 |
2200 draw_cache_.uv_xform_location = binding.tex_transform_location; | 2207 draw_cache_.uv_xform_location = binding.tex_transform_location; |
2201 draw_cache_.background_color_location = binding.background_color_location; | 2208 draw_cache_.background_color_location = binding.background_color_location; |
2202 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location; | 2209 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location; |
2203 draw_cache_.matrix_location = binding.matrix_location; | 2210 draw_cache_.matrix_location = binding.matrix_location; |
2204 draw_cache_.sampler_location = binding.sampler_location; | 2211 draw_cache_.sampler_location = binding.sampler_location; |
2205 } | 2212 } |
2206 | 2213 |
2207 // Generate the uv-transform | 2214 // Generate the uv-transform |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3358 context_support_->ScheduleOverlayPlane( | 3365 context_support_->ScheduleOverlayPlane( |
3359 overlay.plane_z_order, | 3366 overlay.plane_z_order, |
3360 overlay.transform, | 3367 overlay.transform, |
3361 pending_overlay_resources_.back()->texture_id(), | 3368 pending_overlay_resources_.back()->texture_id(), |
3362 overlay.display_rect, | 3369 overlay.display_rect, |
3363 overlay.uv_rect); | 3370 overlay.uv_rect); |
3364 } | 3371 } |
3365 } | 3372 } |
3366 | 3373 |
3367 } // namespace cc | 3374 } // namespace cc |
OLD | NEW |