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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 always_clear = true; | 445 always_clear = true; |
446 #endif | 446 #endif |
447 if (always_clear || frame->current_render_pass->has_transparent_background) { | 447 if (always_clear || frame->current_render_pass->has_transparent_background) { |
448 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; | 448 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; |
449 if (always_clear) | 449 if (always_clear) |
450 clear_bits |= GL_STENCIL_BUFFER_BIT; | 450 clear_bits |= GL_STENCIL_BUFFER_BIT; |
451 gl_->Clear(clear_bits); | 451 gl_->Clear(clear_bits); |
452 } | 452 } |
453 } | 453 } |
454 | 454 |
455 static ResourceProvider::ResourceId WaitOnResourceSyncPoints( | 455 static ResourceId WaitOnResourceSyncPoints(ResourceProvider* resource_provider, |
456 ResourceProvider* resource_provider, | 456 ResourceId resource_id) { |
457 ResourceProvider::ResourceId resource_id) { | |
458 resource_provider->WaitSyncPointIfNeeded(resource_id); | 457 resource_provider->WaitSyncPointIfNeeded(resource_id); |
459 return resource_id; | 458 return resource_id; |
460 } | 459 } |
461 | 460 |
462 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { | 461 void GLRenderer::BeginDrawingFrame(DrawingFrame* frame) { |
463 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); | 462 TRACE_EVENT0("cc", "GLRenderer::BeginDrawingFrame"); |
464 | 463 |
465 scoped_refptr<ResourceProvider::Fence> read_lock_fence; | 464 scoped_refptr<ResourceProvider::Fence> read_lock_fence; |
466 if (use_sync_query_) { | 465 if (use_sync_query_) { |
467 // Block until oldest sync query has passed if the number of pending queries | 466 // Block until oldest sync query has passed if the number of pending queries |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 } | 1633 } |
1635 | 1634 |
1636 void GLRenderer::DrawTileQuad(const DrawingFrame* frame, | 1635 void GLRenderer::DrawTileQuad(const DrawingFrame* frame, |
1637 const TileDrawQuad* quad, | 1636 const TileDrawQuad* quad, |
1638 const gfx::QuadF* clip_region) { | 1637 const gfx::QuadF* clip_region) { |
1639 DrawContentQuad(frame, quad, quad->resource_id, clip_region); | 1638 DrawContentQuad(frame, quad, quad->resource_id, clip_region); |
1640 } | 1639 } |
1641 | 1640 |
1642 void GLRenderer::DrawContentQuad(const DrawingFrame* frame, | 1641 void GLRenderer::DrawContentQuad(const DrawingFrame* frame, |
1643 const ContentDrawQuadBase* quad, | 1642 const ContentDrawQuadBase* quad, |
1644 ResourceProvider::ResourceId resource_id, | 1643 ResourceId resource_id, |
1645 const gfx::QuadF* clip_region) { | 1644 const gfx::QuadF* clip_region) { |
1646 gfx::Transform device_transform = | 1645 gfx::Transform device_transform = |
1647 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); | 1646 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); |
1648 device_transform.FlattenTo2d(); | 1647 device_transform.FlattenTo2d(); |
1649 | 1648 |
1650 bool use_aa = settings_->allow_antialiasing && | 1649 bool use_aa = settings_->allow_antialiasing && |
1651 ShouldAntialiasQuad(device_transform, quad, false); | 1650 ShouldAntialiasQuad(device_transform, quad, false); |
1652 | 1651 |
1653 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA | 1652 // TODO(timav): simplify coordinate transformations in DrawContentQuadAA |
1654 // similar to the way DrawContentQuadNoAA works and then consider | 1653 // similar to the way DrawContentQuadNoAA works and then consider |
1655 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method. | 1654 // combining DrawContentQuadAA and DrawContentQuadNoAA into one method. |
1656 if (use_aa) | 1655 if (use_aa) |
1657 DrawContentQuadAA(frame, quad, resource_id, device_transform, clip_region); | 1656 DrawContentQuadAA(frame, quad, resource_id, device_transform, clip_region); |
1658 else | 1657 else |
1659 DrawContentQuadNoAA(frame, quad, resource_id, clip_region); | 1658 DrawContentQuadNoAA(frame, quad, resource_id, clip_region); |
1660 } | 1659 } |
1661 | 1660 |
1662 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame, | 1661 void GLRenderer::DrawContentQuadAA(const DrawingFrame* frame, |
1663 const ContentDrawQuadBase* quad, | 1662 const ContentDrawQuadBase* quad, |
1664 ResourceProvider::ResourceId resource_id, | 1663 ResourceId resource_id, |
1665 const gfx::Transform& device_transform, | 1664 const gfx::Transform& device_transform, |
1666 const gfx::QuadF* clip_region) { | 1665 const gfx::QuadF* clip_region) { |
1667 if (!device_transform.IsInvertible()) | 1666 if (!device_transform.IsInvertible()) |
1668 return; | 1667 return; |
1669 | 1668 |
1670 gfx::Rect tile_rect = quad->visible_rect; | 1669 gfx::Rect tile_rect = quad->visible_rect; |
1671 | 1670 |
1672 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( | 1671 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( |
1673 quad->tex_coord_rect, quad->rect, tile_rect); | 1672 quad->tex_coord_rect, quad->rect, tile_rect); |
1674 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); | 1673 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 // it. This is why this centered rect is used and not the original quad_rect. | 1773 // it. This is why this centered rect is used and not the original quad_rect. |
1775 gfx::RectF centered_rect( | 1774 gfx::RectF centered_rect( |
1776 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), | 1775 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), |
1777 tile_rect.size()); | 1776 tile_rect.size()); |
1778 DrawQuadGeometry( | 1777 DrawQuadGeometry( |
1779 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); | 1778 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); |
1780 } | 1779 } |
1781 | 1780 |
1782 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, | 1781 void GLRenderer::DrawContentQuadNoAA(const DrawingFrame* frame, |
1783 const ContentDrawQuadBase* quad, | 1782 const ContentDrawQuadBase* quad, |
1784 ResourceProvider::ResourceId resource_id, | 1783 ResourceId resource_id, |
1785 const gfx::QuadF* clip_region) { | 1784 const gfx::QuadF* clip_region) { |
1786 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( | 1785 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( |
1787 quad->tex_coord_rect, quad->rect, quad->visible_rect); | 1786 quad->tex_coord_rect, quad->rect, quad->visible_rect); |
1788 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); | 1787 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); |
1789 float tex_to_geom_scale_y = | 1788 float tex_to_geom_scale_y = |
1790 quad->rect.height() / quad->tex_coord_rect.height(); | 1789 quad->rect.height() / quad->tex_coord_rect.height(); |
1791 | 1790 |
1792 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); | 1791 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); |
1793 GLenum filter = | 1792 GLenum filter = |
1794 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) && | 1793 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) && |
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3507 context_support_->ScheduleOverlayPlane( | 3506 context_support_->ScheduleOverlayPlane( |
3508 overlay.plane_z_order, | 3507 overlay.plane_z_order, |
3509 overlay.transform, | 3508 overlay.transform, |
3510 pending_overlay_resources_.back()->texture_id(), | 3509 pending_overlay_resources_.back()->texture_id(), |
3511 ToNearestRect(overlay.display_rect), | 3510 ToNearestRect(overlay.display_rect), |
3512 overlay.uv_rect); | 3511 overlay.uv_rect); |
3513 } | 3512 } |
3514 } | 3513 } |
3515 | 3514 |
3516 } // namespace cc | 3515 } // namespace cc |
OLD | NEW |