Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 105103004: Convert cc resource system over to GLES2Interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cc/resources/resource_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 gl_->Clear(clear_bits); 303 gl_->Clear(clear_bits);
304 } 304 }
305 } 305 }
306 306
307 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { 307 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) {
308 if (frame->device_viewport_rect.IsEmpty()) 308 if (frame->device_viewport_rect.IsEmpty())
309 return; 309 return;
310 310
311 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); 311 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame");
312 312
313 // TODO(enne): Do we need to reinitialize all of this state per frame?
313 ReinitializeGLState(); 314 ReinitializeGLState();
314 } 315 }
315 316
316 void GLRenderer::DoNoOp() { 317 void GLRenderer::DoNoOp() {
317 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); 318 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0));
318 GLC(gl_, gl_->Flush()); 319 GLC(gl_, gl_->Flush());
319 } 320 }
320 321
321 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) { 322 void GLRenderer::DoDrawQuad(DrawingFrame* frame, const DrawQuad* quad) {
322 DCHECK(quad->rect.Contains(quad->visible_rect)); 323 DCHECK(quad->rect.Contains(quad->visible_rect));
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 mask_texture_id = mask_resource_lock->texture_id(); 924 mask_texture_id = mask_resource_lock->texture_id();
924 } 925 }
925 926
926 // TODO(danakj): use the background_texture and blend the background in with 927 // TODO(danakj): use the background_texture and blend the background in with
927 // this draw instead of having a separate copy of the background texture. 928 // this draw instead of having a separate copy of the background texture.
928 929
929 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; 930 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock;
930 if (filter_bitmap.getTexture()) { 931 if (filter_bitmap.getTexture()) {
931 GrTexture* texture = 932 GrTexture* texture =
932 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); 933 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture());
933 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 934 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_));
934 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); 935 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
935 } else { 936 } else {
936 contents_resource_lock = 937 contents_resource_lock =
937 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( 938 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL(
938 resource_provider_, contents_texture->id(), GL_LINEAR)); 939 resource_provider_, contents_texture->id(), GL_LINEAR));
939 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 940 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
940 contents_resource_lock->target()); 941 contents_resource_lock->target());
941 } 942 }
942 943
943 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 944 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 GetVideoStreamTextureProgram(tex_coord_precision); 1679 GetVideoStreamTextureProgram(tex_coord_precision);
1679 SetUseProgram(program->program()); 1680 SetUseProgram(program->program());
1680 1681
1681 ToGLMatrix(&gl_matrix[0], quad->matrix); 1682 ToGLMatrix(&gl_matrix[0], quad->matrix);
1682 GLC(gl_, 1683 GLC(gl_,
1683 gl_->UniformMatrix4fv( 1684 gl_->UniformMatrix4fv(
1684 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); 1685 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix));
1685 1686
1686 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 1687 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1687 quad->resource_id); 1688 quad->resource_id);
1688 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 1689 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_));
1689 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id())); 1690 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()));
1690 1691
1691 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 1692 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0));
1692 1693
1693 SetShaderOpacity(quad->opacity(), 1694 SetShaderOpacity(quad->opacity(),
1694 program->fragment_shader().alpha_location()); 1695 program->fragment_shader().alpha_location());
1695 DrawQuadGeometry(frame, 1696 DrawQuadGeometry(frame,
1696 quad->quadTransform(), 1697 quad->quadTransform(),
1697 quad->rect, 1698 quad->rect,
1698 program->vertex_shader().matrix_location()); 1699 program->vertex_shader().matrix_location());
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 1789
1789 // Bind the program to the GL state. 1790 // Bind the program to the GL state.
1790 SetUseProgram(draw_cache_.program_id); 1791 SetUseProgram(draw_cache_.program_id);
1791 1792
1792 // Bind the correct texture sampler location. 1793 // Bind the correct texture sampler location.
1793 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); 1794 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0));
1794 1795
1795 // Assume the current active textures is 0. 1796 // Assume the current active textures is 0.
1796 ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_, 1797 ResourceProvider::ScopedReadLockGL locked_quad(resource_provider_,
1797 draw_cache_.resource_id); 1798 draw_cache_.resource_id);
1798 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 1799 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_));
1799 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id())); 1800 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id()));
1800 1801
1801 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), // NOLINT(runtime/sizeof) 1802 COMPILE_ASSERT(sizeof(Float4) == 4 * sizeof(float), // NOLINT(runtime/sizeof)
1802 struct_is_densely_packed); 1803 struct_is_densely_packed);
1803 COMPILE_ASSERT( 1804 COMPILE_ASSERT(
1804 sizeof(Float16) == 16 * sizeof(float), // NOLINT(runtime/sizeof) 1805 sizeof(Float16) == 16 * sizeof(float), // NOLINT(runtime/sizeof)
1805 struct_is_densely_packed); 1806 struct_is_densely_packed);
1806 1807
1807 // Upload the tranforms for both points and uvs. 1808 // Upload the tranforms for both points and uvs.
1808 GLC(gl_, 1809 GLC(gl_,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 quad->io_surface_size.width(), 1940 quad->io_surface_size.width(),
1940 quad->io_surface_size.height())); 1941 quad->io_surface_size.height()));
1941 } 1942 }
1942 1943
1943 const float vertex_opacity[] = {quad->opacity(), quad->opacity(), 1944 const float vertex_opacity[] = {quad->opacity(), quad->opacity(),
1944 quad->opacity(), quad->opacity()}; 1945 quad->opacity(), quad->opacity()};
1945 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity)); 1946 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity));
1946 1947
1947 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 1948 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
1948 quad->io_surface_resource_id); 1949 quad->io_surface_resource_id);
1949 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 1950 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_));
1950 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id())); 1951 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id()));
1951 1952
1952 DrawQuadGeometry( 1953 DrawQuadGeometry(
1953 frame, quad->quadTransform(), quad->rect, binding.matrix_location); 1954 frame, quad->quadTransform(), quad->rect, binding.matrix_location);
1954 1955
1955 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); 1956 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0));
1956 } 1957 }
1957 1958
1958 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 1959 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
1959 current_framebuffer_lock_.reset(); 1960 current_framebuffer_lock_.reset();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 } else { 2085 } else {
2085 GLC(gl_, 2086 GLC(gl_,
2086 gl_->Uniform4f(program->vertex_shader().tex_transform_location(), 2087 gl_->Uniform4f(program->vertex_shader().tex_transform_location(),
2087 0.f, 2088 0.f,
2088 0.f, 2089 0.f,
2089 1.f, 2090 1.f,
2090 1.f)); 2091 1.f));
2091 } 2092 }
2092 2093
2093 SetShaderOpacity(1.f, program->fragment_shader().alpha_location()); 2094 SetShaderOpacity(1.f, program->fragment_shader().alpha_location());
2094 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(Context())); 2095 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_));
2095 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); 2096 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id));
2096 DrawQuadGeometry( 2097 DrawQuadGeometry(
2097 frame, draw_matrix, rect, program->vertex_shader().matrix_location()); 2098 frame, draw_matrix, rect, program->vertex_shader().matrix_location());
2098 } 2099 }
2099 2100
2100 void GLRenderer::Finish() { 2101 void GLRenderer::Finish() {
2101 TRACE_EVENT0("cc", "GLRenderer::Finish"); 2102 TRACE_EVENT0("cc", "GLRenderer::Finish");
2102 GLC(gl_, gl_->Finish()); 2103 GLC(gl_, gl_->Finish());
2103 } 2104 }
2104 2105
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 is_scissor_enabled_ = false; 3005 is_scissor_enabled_ = false;
3005 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 3006 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST));
3006 scissor_rect_needs_reset_ = true; 3007 scissor_rect_needs_reset_ = true;
3007 } 3008 }
3008 3009
3009 bool GLRenderer::IsContextLost() { 3010 bool GLRenderer::IsContextLost() {
3010 return output_surface_->context_provider()->IsContextLost(); 3011 return output_surface_->context_provider()->IsContextLost();
3011 } 3012 }
3012 3013
3013 } // namespace cc 3014 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698