Chromium Code Reviews| 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 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 mask_texture_id = mask_resource_lock->texture_id(); | 1059 mask_texture_id = mask_resource_lock->texture_id(); | 
| 1060 } | 1060 } | 
| 1061 | 1061 | 
| 1062 // TODO(danakj): use the background_texture and blend the background in with | 1062 // TODO(danakj): use the background_texture and blend the background in with | 
| 1063 // this draw instead of having a separate copy of the background texture. | 1063 // this draw instead of having a separate copy of the background texture. | 
| 1064 | 1064 | 
| 1065 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; | 1065 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; | 
| 1066 if (filter_bitmap.getTexture()) { | 1066 if (filter_bitmap.getTexture()) { | 
| 1067 GrTexture* texture = | 1067 GrTexture* texture = | 
| 1068 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); | 1068 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); | 
| 1069 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 1069 DCHECK_EQ(GL_TEXTURE0, ResourceHelper::GetActiveTextureUnit(gl_)); | 
| 
 
danakj
2014/07/09 16:01:33
This function is super simple I don't think we nee
 
sohanjg
2014/07/10 15:11:06
Done.
 
 | |
| 1070 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 1070 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 
| 1071 } else { | 1071 } else { | 
| 1072 contents_resource_lock = | 1072 contents_resource_lock = | 
| 1073 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( | 1073 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( | 
| 1074 resource_provider_, contents_texture->id(), GL_LINEAR)); | 1074 resource_provider_, contents_texture->id(), GL_LINEAR)); | 
| 1075 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1075 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 
| 1076 contents_resource_lock->target()); | 1076 contents_resource_lock->target()); | 
| 1077 } | 1077 } | 
| 1078 | 1078 | 
| 1079 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1079 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1847 GetVideoStreamTextureProgram(tex_coord_precision); | 1847 GetVideoStreamTextureProgram(tex_coord_precision); | 
| 1848 SetUseProgram(program->program()); | 1848 SetUseProgram(program->program()); | 
| 1849 | 1849 | 
| 1850 ToGLMatrix(&gl_matrix[0], quad->matrix); | 1850 ToGLMatrix(&gl_matrix[0], quad->matrix); | 
| 1851 GLC(gl_, | 1851 GLC(gl_, | 
| 1852 gl_->UniformMatrix4fv( | 1852 gl_->UniformMatrix4fv( | 
| 1853 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); | 1853 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); | 
| 1854 | 1854 | 
| 1855 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 1855 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 
| 1856 quad->resource_id); | 1856 quad->resource_id); | 
| 1857 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 1857 DCHECK_EQ(GL_TEXTURE0, ResourceHelper::GetActiveTextureUnit(gl_)); | 
| 1858 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id())); | 1858 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id())); | 
| 1859 | 1859 | 
| 1860 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 1860 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); | 
| 1861 | 1861 | 
| 1862 SetShaderOpacity(quad->opacity(), | 1862 SetShaderOpacity(quad->opacity(), | 
| 1863 program->fragment_shader().alpha_location()); | 1863 program->fragment_shader().alpha_location()); | 
| 1864 DrawQuadGeometry(frame, | 1864 DrawQuadGeometry(frame, | 
| 1865 quad->quadTransform(), | 1865 quad->quadTransform(), | 
| 1866 quad->rect, | 1866 quad->rect, | 
| 1867 program->vertex_shader().matrix_location()); | 1867 program->vertex_shader().matrix_location()); | 
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1957 | 1957 | 
| 1958 // Bind the program to the GL state. | 1958 // Bind the program to the GL state. | 
| 1959 SetUseProgram(draw_cache_.program_id); | 1959 SetUseProgram(draw_cache_.program_id); | 
| 1960 | 1960 | 
| 1961 // Bind the correct texture sampler location. | 1961 // Bind the correct texture sampler location. | 
| 1962 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); | 1962 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); | 
| 1963 | 1963 | 
| 1964 // Assume the current active textures is 0. | 1964 // Assume the current active textures is 0. | 
| 1965 ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_, | 1965 ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_, | 
| 1966 draw_cache_.resource_id); | 1966 draw_cache_.resource_id); | 
| 1967 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 1967 DCHECK_EQ(GL_TEXTURE0, ResourceHelper::GetActiveTextureUnit(gl_)); | 
| 1968 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id())); | 1968 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id())); | 
| 1969 | 1969 | 
| 1970 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed); | 1970 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), struct_is_densely_packed); | 
| 1971 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float), | 1971 COMPILE_ASSERT(sizeof(Float16) == 16 * sizeof(float), | 
| 1972 struct_is_densely_packed); | 1972 struct_is_densely_packed); | 
| 1973 | 1973 | 
| 1974 // Upload the tranforms for both points and uvs. | 1974 // Upload the tranforms for both points and uvs. | 
| 1975 GLC(gl_, | 1975 GLC(gl_, | 
| 1976 gl_->UniformMatrix4fv( | 1976 gl_->UniformMatrix4fv( | 
| 1977 static_cast<int>(draw_cache_.matrix_location), | 1977 static_cast<int>(draw_cache_.matrix_location), | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2106 quad->io_surface_size.width(), | 2106 quad->io_surface_size.width(), | 
| 2107 quad->io_surface_size.height())); | 2107 quad->io_surface_size.height())); | 
| 2108 } | 2108 } | 
| 2109 | 2109 | 
| 2110 const float vertex_opacity[] = {quad->opacity(), quad->opacity(), | 2110 const float vertex_opacity[] = {quad->opacity(), quad->opacity(), | 
| 2111 quad->opacity(), quad->opacity()}; | 2111 quad->opacity(), quad->opacity()}; | 
| 2112 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity)); | 2112 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity)); | 
| 2113 | 2113 | 
| 2114 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 2114 ResourceProvider::ScopedReadLockGL lock(resource_provider_, | 
| 2115 quad->io_surface_resource_id); | 2115 quad->io_surface_resource_id); | 
| 2116 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 2116 DCHECK_EQ(GL_TEXTURE0, ResourceHelper::GetActiveTextureUnit(gl_)); | 
| 2117 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id())); | 2117 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id())); | 
| 2118 | 2118 | 
| 2119 DrawQuadGeometry( | 2119 DrawQuadGeometry( | 
| 2120 frame, quad->quadTransform(), quad->rect, binding.matrix_location); | 2120 frame, quad->quadTransform(), quad->rect, binding.matrix_location); | 
| 2121 | 2121 | 
| 2122 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); | 2122 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); | 
| 2123 } | 2123 } | 
| 2124 | 2124 | 
| 2125 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 2125 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { | 
| 2126 if (use_sync_query_) { | 2126 if (use_sync_query_) { | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2259 } else { | 2259 } else { | 
| 2260 GLC(gl_, | 2260 GLC(gl_, | 
| 2261 gl_->Uniform4f(program->vertex_shader().tex_transform_location(), | 2261 gl_->Uniform4f(program->vertex_shader().tex_transform_location(), | 
| 2262 0.f, | 2262 0.f, | 
| 2263 0.f, | 2263 0.f, | 
| 2264 1.f, | 2264 1.f, | 
| 2265 1.f)); | 2265 1.f)); | 
| 2266 } | 2266 } | 
| 2267 | 2267 | 
| 2268 SetShaderOpacity(1.f, program->fragment_shader().alpha_location()); | 2268 SetShaderOpacity(1.f, program->fragment_shader().alpha_location()); | 
| 2269 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); | 2269 DCHECK_EQ(GL_TEXTURE0, ResourceHelper::GetActiveTextureUnit(gl_)); | 
| 2270 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); | 2270 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); | 
| 2271 DrawQuadGeometry( | 2271 DrawQuadGeometry( | 
| 2272 frame, draw_matrix, rect, program->vertex_shader().matrix_location()); | 2272 frame, draw_matrix, rect, program->vertex_shader().matrix_location()); | 
| 2273 } | 2273 } | 
| 2274 | 2274 | 
| 2275 void GLRenderer::Finish() { | 2275 void GLRenderer::Finish() { | 
| 2276 TRACE_EVENT0("cc", "GLRenderer::Finish"); | 2276 TRACE_EVENT0("cc", "GLRenderer::Finish"); | 
| 2277 GLC(gl_, gl_->Finish()); | 2277 GLC(gl_, gl_->Finish()); | 
| 2278 } | 2278 } | 
| 2279 | 2279 | 
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3165 context_support_->ScheduleOverlayPlane( | 3165 context_support_->ScheduleOverlayPlane( | 
| 3166 overlay.plane_z_order, | 3166 overlay.plane_z_order, | 
| 3167 overlay.transform, | 3167 overlay.transform, | 
| 3168 pending_overlay_resources_.back()->texture_id(), | 3168 pending_overlay_resources_.back()->texture_id(), | 
| 3169 overlay.display_rect, | 3169 overlay.display_rect, | 
| 3170 overlay.uv_rect); | 3170 overlay.uv_rect); | 
| 3171 } | 3171 } | 
| 3172 } | 3172 } | 
| 3173 | 3173 | 
| 3174 } // namespace cc | 3174 } // namespace cc | 
| OLD | NEW |