| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 params->dst_rect.width(), params->dst_rect.height()); | 1398 params->dst_rect.width(), params->dst_rect.height()); |
| 1399 gfx::Size texture_size; | 1399 gfx::Size texture_size; |
| 1400 if (params->filter_image) { | 1400 if (params->filter_image) { |
| 1401 texture_size.set_width(params->filter_image->width()); | 1401 texture_size.set_width(params->filter_image->width()); |
| 1402 texture_size.set_height(params->filter_image->height()); | 1402 texture_size.set_height(params->filter_image->height()); |
| 1403 } else { | 1403 } else { |
| 1404 texture_size = params->contents_texture->size(); | 1404 texture_size = params->contents_texture->size(); |
| 1405 } | 1405 } |
| 1406 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height()); | 1406 tex_rect.Scale(1.0f / texture_size.width(), 1.0f / texture_size.height()); |
| 1407 | 1407 |
| 1408 DCHECK(locations.tex_transform != -1 || IsContextLost()); | 1408 DCHECK(locations.vertex_tex_transform != -1 || IsContextLost()); |
| 1409 if (params->source_needs_flip) { | 1409 if (params->source_needs_flip) { |
| 1410 // Flip the content vertically in the shader, as the RenderPass input | 1410 // Flip the content vertically in the shader, as the RenderPass input |
| 1411 // texture is already oriented the same way as the framebuffer, but the | 1411 // texture is already oriented the same way as the framebuffer, but the |
| 1412 // projection transform does a flip. | 1412 // projection transform does a flip. |
| 1413 gl_->Uniform4f(locations.tex_transform, tex_rect.x(), 1.0f - tex_rect.y(), | 1413 gl_->Uniform4f(locations.vertex_tex_transform, tex_rect.x(), |
| 1414 tex_rect.width(), -tex_rect.height()); | 1414 1.0f - tex_rect.y(), tex_rect.width(), -tex_rect.height()); |
| 1415 } else { | 1415 } else { |
| 1416 // Tile textures are oriented opposite the framebuffer, so can use | 1416 // Tile textures are oriented opposite the framebuffer, so can use |
| 1417 // the projection transform to do the flip. | 1417 // the projection transform to do the flip. |
| 1418 gl_->Uniform4f(locations.tex_transform, tex_rect.x(), tex_rect.y(), | 1418 gl_->Uniform4f(locations.vertex_tex_transform, tex_rect.x(), tex_rect.y(), |
| 1419 tex_rect.width(), tex_rect.height()); | 1419 tex_rect.width(), tex_rect.height()); |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 GLint last_texture_unit = 0; | 1422 GLint last_texture_unit = 0; |
| 1423 if (locations.mask_sampler != -1) { | 1423 if (locations.mask_sampler != -1) { |
| 1424 DCHECK(params->mask_resource_lock); | 1424 DCHECK(params->mask_resource_lock); |
| 1425 DCHECK_NE(locations.mask_tex_coord_scale, 1); | 1425 DCHECK_NE(locations.mask_tex_coord_scale, 1); |
| 1426 DCHECK_NE(locations.mask_tex_coord_offset, 1); | 1426 DCHECK_NE(locations.mask_tex_coord_offset, 1); |
| 1427 gl_->Uniform1i(locations.mask_sampler, 1); | 1427 gl_->Uniform1i(locations.mask_sampler, 1); |
| 1428 | 1428 |
| (...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2534 int sampler_location; | 2534 int sampler_location; |
| 2535 int matrix_location; | 2535 int matrix_location; |
| 2536 int transform_location; | 2536 int transform_location; |
| 2537 int background_color_location; | 2537 int background_color_location; |
| 2538 }; | 2538 }; |
| 2539 | 2539 |
| 2540 struct TexTransformTextureProgramBinding : TextureProgramBinding { | 2540 struct TexTransformTextureProgramBinding : TextureProgramBinding { |
| 2541 template <class Program> | 2541 template <class Program> |
| 2542 void Set(Program* program) { | 2542 void Set(Program* program) { |
| 2543 TextureProgramBinding::Set(program); | 2543 TextureProgramBinding::Set(program); |
| 2544 tex_transform_location = program->vertex_shader().tex_transform_location(); | 2544 vertex_tex_transform_location = |
| 2545 program->vertex_shader().vertex_tex_transform_location(); |
| 2545 vertex_opacity_location = | 2546 vertex_opacity_location = |
| 2546 program->vertex_shader().vertex_opacity_location(); | 2547 program->vertex_shader().vertex_opacity_location(); |
| 2547 } | 2548 } |
| 2548 int tex_transform_location; | 2549 int vertex_tex_transform_location; |
| 2549 int vertex_opacity_location; | 2550 int vertex_opacity_location; |
| 2550 }; | 2551 }; |
| 2551 | 2552 |
| 2552 void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) { | 2553 void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) { |
| 2553 // Check to see if we have anything to draw. | 2554 // Check to see if we have anything to draw. |
| 2554 if (draw_cache_.program_id == -1) | 2555 if (draw_cache_.program_id == -1) |
| 2555 return; | 2556 return; |
| 2556 | 2557 |
| 2557 PrepareGeometry(flush_binding); | 2558 PrepareGeometry(flush_binding); |
| 2558 | 2559 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2686 draw_cache_.nearest_neighbor != quad->nearest_neighbor || | 2687 draw_cache_.nearest_neighbor != quad->nearest_neighbor || |
| 2687 draw_cache_.background_color != quad->background_color || | 2688 draw_cache_.background_color != quad->background_color || |
| 2688 draw_cache_.matrix_data.size() >= max_quads) { | 2689 draw_cache_.matrix_data.size() >= max_quads) { |
| 2689 FlushTextureQuadCache(SHARED_BINDING); | 2690 FlushTextureQuadCache(SHARED_BINDING); |
| 2690 draw_cache_.program_id = binding.program_id; | 2691 draw_cache_.program_id = binding.program_id; |
| 2691 draw_cache_.resource_id = resource_id; | 2692 draw_cache_.resource_id = resource_id; |
| 2692 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); | 2693 draw_cache_.needs_blending = quad->ShouldDrawWithBlending(); |
| 2693 draw_cache_.nearest_neighbor = quad->nearest_neighbor; | 2694 draw_cache_.nearest_neighbor = quad->nearest_neighbor; |
| 2694 draw_cache_.background_color = quad->background_color; | 2695 draw_cache_.background_color = quad->background_color; |
| 2695 | 2696 |
| 2696 draw_cache_.uv_xform_location = binding.tex_transform_location; | 2697 draw_cache_.uv_xform_location = binding.vertex_tex_transform_location; |
| 2697 draw_cache_.background_color_location = binding.background_color_location; | 2698 draw_cache_.background_color_location = binding.background_color_location; |
| 2698 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location; | 2699 draw_cache_.vertex_opacity_location = binding.vertex_opacity_location; |
| 2699 draw_cache_.matrix_location = binding.matrix_location; | 2700 draw_cache_.matrix_location = binding.matrix_location; |
| 2700 draw_cache_.sampler_location = binding.sampler_location; | 2701 draw_cache_.sampler_location = binding.sampler_location; |
| 2701 } | 2702 } |
| 2702 | 2703 |
| 2703 // Generate the uv-transform | 2704 // Generate the uv-transform |
| 2704 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; | 2705 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; |
| 2705 if (!clip_region) | 2706 if (!clip_region) |
| 2706 uv_transform = UVTransform(quad); | 2707 uv_transform = UVTransform(quad); |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4058 // The alpha has already been applied when copying the RPDQ to an IOSurface. | 4059 // The alpha has already been applied when copying the RPDQ to an IOSurface. |
| 4059 GLfloat alpha = 1; | 4060 GLfloat alpha = 1; |
| 4060 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, | 4061 gl_->ScheduleCALayerSharedStateCHROMIUM(alpha, is_clipped, clip_rect, |
| 4061 sorting_context_id, gl_transform); | 4062 sorting_context_id, gl_transform); |
| 4062 gl_->ScheduleCALayerCHROMIUM( | 4063 gl_->ScheduleCALayerCHROMIUM( |
| 4063 texture_id, contents_rect, ca_layer_overlay->background_color, | 4064 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4064 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4065 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4065 } | 4066 } |
| 4066 | 4067 |
| 4067 } // namespace cc | 4068 } // namespace cc |
| OLD | NEW |