| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 static GLint GetActiveTextureUnit(GLES2Interface* gl) { | 147 static GLint GetActiveTextureUnit(GLES2Interface* gl) { |
| 148 GLint active_unit = 0; | 148 GLint active_unit = 0; |
| 149 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 149 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
| 150 return active_unit; | 150 return active_unit; |
| 151 } | 151 } |
| 152 | 152 |
| 153 class GLRenderer::ScopedUseGrContext { | 153 class GLRenderer::ScopedUseGrContext { |
| 154 public: | 154 public: |
| 155 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, | 155 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, |
| 156 DrawingFrame* frame) { | 156 DrawingFrame* frame) { |
| 157 if (!renderer->output_surface_->context_provider()->GrContext()) | |
| 158 return nullptr; | |
| 159 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); | 157 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); |
| 160 } | 158 } |
| 161 | 159 |
| 162 ~ScopedUseGrContext() { PassControlToGLRenderer(); } | 160 ~ScopedUseGrContext() { PassControlToGLRenderer(); } |
| 163 | 161 |
| 164 GrContext* context() const { | 162 GrContext* context() const { |
| 165 return renderer_->output_surface_->context_provider()->GrContext(); | 163 return renderer_->output_surface_->context_provider()->GrContext(); |
| 166 } | 164 } |
| 167 | 165 |
| 168 private: | 166 private: |
| (...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); | 1618 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); |
| 1621 | 1619 |
| 1622 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( | 1620 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( |
| 1623 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); | 1621 gl_, &highp_threshold_cache_, highp_threshold_min_, quad->texture_size); |
| 1624 | 1622 |
| 1625 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); | 1623 gfx::QuadF local_quad = gfx::QuadF(gfx::RectF(tile_rect)); |
| 1626 float edge[24]; | 1624 float edge[24]; |
| 1627 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); | 1625 SetupQuadForAntialiasing(device_transform, quad, &local_quad, edge); |
| 1628 | 1626 |
| 1629 ResourceProvider::ScopedSamplerGL quad_resource_lock( | 1627 ResourceProvider::ScopedSamplerGL quad_resource_lock( |
| 1630 resource_provider_, resource_id, GL_LINEAR); | 1628 resource_provider_, resource_id, |
| 1629 quad->nearest_neighbor ? GL_NEAREST : GL_LINEAR); |
| 1631 SamplerType sampler = | 1630 SamplerType sampler = |
| 1632 SamplerTypeFromTextureTarget(quad_resource_lock.target()); | 1631 SamplerTypeFromTextureTarget(quad_resource_lock.target()); |
| 1633 | 1632 |
| 1634 float fragment_tex_translate_x = clamp_tex_rect.x(); | 1633 float fragment_tex_translate_x = clamp_tex_rect.x(); |
| 1635 float fragment_tex_translate_y = clamp_tex_rect.y(); | 1634 float fragment_tex_translate_y = clamp_tex_rect.y(); |
| 1636 float fragment_tex_scale_x = clamp_tex_rect.width(); | 1635 float fragment_tex_scale_x = clamp_tex_rect.width(); |
| 1637 float fragment_tex_scale_y = clamp_tex_rect.height(); | 1636 float fragment_tex_scale_y = clamp_tex_rect.height(); |
| 1638 | 1637 |
| 1639 // Map to normalized texture coordinates. | 1638 // Map to normalized texture coordinates. |
| 1640 if (sampler != SamplerType2DRect) { | 1639 if (sampler != SamplerType2DRect) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 const ContentDrawQuadBase* quad, | 1703 const ContentDrawQuadBase* quad, |
| 1705 ResourceProvider::ResourceId resource_id) { | 1704 ResourceProvider::ResourceId resource_id) { |
| 1706 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( | 1705 gfx::RectF tex_coord_rect = MathUtil::ScaleRectProportional( |
| 1707 quad->tex_coord_rect, quad->rect, quad->visible_rect); | 1706 quad->tex_coord_rect, quad->rect, quad->visible_rect); |
| 1708 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); | 1707 float tex_to_geom_scale_x = quad->rect.width() / quad->tex_coord_rect.width(); |
| 1709 float tex_to_geom_scale_y = | 1708 float tex_to_geom_scale_y = |
| 1710 quad->rect.height() / quad->tex_coord_rect.height(); | 1709 quad->rect.height() / quad->tex_coord_rect.height(); |
| 1711 | 1710 |
| 1712 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); | 1711 bool scaled = (tex_to_geom_scale_x != 1.f || tex_to_geom_scale_y != 1.f); |
| 1713 GLenum filter = | 1712 GLenum filter = |
| 1714 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) | 1713 (scaled || !quad->quadTransform().IsIdentityOrIntegerTranslation()) && |
| 1714 !quad->nearest_neighbor |
| 1715 ? GL_LINEAR | 1715 ? GL_LINEAR |
| 1716 : GL_NEAREST; | 1716 : GL_NEAREST; |
| 1717 | 1717 |
| 1718 ResourceProvider::ScopedSamplerGL quad_resource_lock( | 1718 ResourceProvider::ScopedSamplerGL quad_resource_lock( |
| 1719 resource_provider_, resource_id, filter); | 1719 resource_provider_, resource_id, filter); |
| 1720 SamplerType sampler = | 1720 SamplerType sampler = |
| 1721 SamplerTypeFromTextureTarget(quad_resource_lock.target()); | 1721 SamplerTypeFromTextureTarget(quad_resource_lock.target()); |
| 1722 | 1722 |
| 1723 float vertex_tex_translate_x = tex_coord_rect.x(); | 1723 float vertex_tex_translate_x = tex_coord_rect.x(); |
| 1724 float vertex_tex_translate_y = tex_coord_rect.y(); | 1724 float vertex_tex_translate_y = tex_coord_rect.y(); |
| (...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3287 context_support_->ScheduleOverlayPlane( | 3287 context_support_->ScheduleOverlayPlane( |
| 3288 overlay.plane_z_order, | 3288 overlay.plane_z_order, |
| 3289 overlay.transform, | 3289 overlay.transform, |
| 3290 pending_overlay_resources_.back()->texture_id(), | 3290 pending_overlay_resources_.back()->texture_id(), |
| 3291 overlay.display_rect, | 3291 overlay.display_rect, |
| 3292 overlay.uv_rect); | 3292 overlay.uv_rect); |
| 3293 } | 3293 } |
| 3294 } | 3294 } |
| 3295 | 3295 |
| 3296 } // namespace cc | 3296 } // namespace cc |
| OLD | NEW |