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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/gl_renderer.h" | 7 #include "cc/gl_renderer.h" |
8 | 8 |
9 #include "FloatQuad.h" | 9 #include "FloatQuad.h" |
10 #include "NotImplemented.h" | 10 #include "NotImplemented.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 if (!renderer->initialize()) | 69 if (!renderer->initialize()) |
70 return scoped_ptr<GLRenderer>(); | 70 return scoped_ptr<GLRenderer>(); |
71 | 71 |
72 return renderer.Pass(); | 72 return renderer.Pass(); |
73 } | 73 } |
74 | 74 |
75 GLRenderer::GLRenderer(RendererClient* client, | 75 GLRenderer::GLRenderer(RendererClient* client, |
76 ResourceProvider* resourceProvider) | 76 ResourceProvider* resourceProvider) |
77 : DirectRenderer(client, resourceProvider) | 77 : DirectRenderer(client, resourceProvider) |
78 , m_offscreenFramebufferId(0) | 78 , m_offscreenFramebufferId(0) |
79 , m_sharedGeometryQuad(FloatRect(-0.5f, -0.5f, 1.0f, 1.0f)) | 79 , m_sharedGeometryQuad(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)) |
80 , m_context(resourceProvider->graphicsContext3D()) | 80 , m_context(resourceProvider->graphicsContext3D()) |
81 , m_isViewportChanged(false) | 81 , m_isViewportChanged(false) |
82 , m_isFramebufferDiscarded(false) | 82 , m_isFramebufferDiscarded(false) |
83 , m_discardFramebufferWhenNotVisible(false) | 83 , m_discardFramebufferWhenNotVisible(false) |
84 , m_isUsingBindUniform(false) | 84 , m_isUsingBindUniform(false) |
85 , m_visible(true) | 85 , m_visible(true) |
86 { | 86 { |
87 DCHECK(m_context); | 87 DCHECK(m_context); |
88 } | 88 } |
89 | 89 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (filters.isEmpty()) | 449 if (filters.isEmpty()) |
450 return scoped_ptr<ScopedTexture>(); | 450 return scoped_ptr<ScopedTexture>(); |
451 | 451 |
452 // FIXME: We only allow background filters on an opaque render surface becau
se other surfaces may contain | 452 // FIXME: We only allow background filters on an opaque render surface becau
se other surfaces may contain |
453 // translucent pixels, and the contents behind those translucent pixels woul
dn't have the filter applied. | 453 // translucent pixels, and the contents behind those translucent pixels woul
dn't have the filter applied. |
454 if (frame.currentRenderPass->hasTransparentBackground()) | 454 if (frame.currentRenderPass->hasTransparentBackground()) |
455 return scoped_ptr<ScopedTexture>(); | 455 return scoped_ptr<ScopedTexture>(); |
456 DCHECK(!frame.currentTexture); | 456 DCHECK(!frame.currentTexture); |
457 | 457 |
458 // FIXME: Do a single readback for both the surface and replica and cache th
e filtered results (once filter textures are not reused). | 458 // FIXME: Do a single readback for both the surface and replica and cache th
e filtered results (once filter textures are not reused). |
459 gfx::Rect deviceRect = gfx::ToEnclosingRect(MathUtil::mapClippedRect(content
sDeviceTransform, cc::FloatRect(sharedGeometryQuad().boundingBox()))); | 459 gfx::Rect deviceRect = gfx::ToEnclosingRect(MathUtil::mapClippedRect(content
sDeviceTransform, sharedGeometryQuad().boundingBox())); |
460 | 460 |
461 int top, right, bottom, left; | 461 int top, right, bottom, left; |
462 filters.getOutsets(top, right, bottom, left); | 462 filters.getOutsets(top, right, bottom, left); |
463 deviceRect.Inset(-left, -top, -right, -bottom); | 463 deviceRect.Inset(-left, -top, -right, -bottom); |
464 | 464 |
465 deviceRect.Intersect(frame.currentRenderPass->outputRect()); | 465 deviceRect.Intersect(frame.currentRenderPass->outputRect()); |
466 | 466 |
467 scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_
resourceProvider); | 467 scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_
resourceProvider); |
468 if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect)) | 468 if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect)) |
469 return scoped_ptr<ScopedTexture>(); | 469 return scoped_ptr<ScopedTexture>(); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 // that could result in sampling outside the layer. | 821 // that could result in sampling outside the layer. |
822 vertexTexScaleX *= fragmentTexScaleX; | 822 vertexTexScaleX *= fragmentTexScaleX; |
823 vertexTexScaleY *= fragmentTexScaleY; | 823 vertexTexScaleY *= fragmentTexScaleY; |
824 vertexTexTranslateX *= fragmentTexScaleX; | 824 vertexTexTranslateX *= fragmentTexScaleX; |
825 vertexTexTranslateY *= fragmentTexScaleY; | 825 vertexTexTranslateY *= fragmentTexScaleY; |
826 vertexTexTranslateX += fragmentTexTranslateX; | 826 vertexTexTranslateX += fragmentTexTranslateX; |
827 vertexTexTranslateY += fragmentTexTranslateY; | 827 vertexTexTranslateY += fragmentTexTranslateY; |
828 | 828 |
829 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation,
vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); | 829 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation,
vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); |
830 | 830 |
831 localQuad = FloatRect(tileRect); | 831 localQuad = gfx::RectF(tileRect); |
832 } | 832 } |
833 | 833 |
834 // Normalize to tileRect. | 834 // Normalize to tileRect. |
835 localQuad.scale(1.0f / tileRect.width(), 1.0f / tileRect.height()); | 835 localQuad.scale(1.0f / tileRect.width(), 1.0f / tileRect.height()); |
836 | 836 |
837 setShaderOpacity(quad->opacity(), uniforms.alphaLocation); | 837 setShaderOpacity(quad->opacity(), uniforms.alphaLocation); |
838 setShaderFloatQuad(localQuad, uniforms.pointLocation); | 838 setShaderFloatQuad(localQuad, uniforms.pointLocation); |
839 | 839 |
840 // The tile quad shader behaves differently compared to all other shaders. | 840 // The tile quad shader behaves differently compared to all other shaders. |
841 // The transform and vertex data are used to figure out the extents that the | 841 // The transform and vertex data are used to figure out the extents that the |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1609 | 1609 |
1610 releaseRenderPassTextures(); | 1610 releaseRenderPassTextures(); |
1611 } | 1611 } |
1612 | 1612 |
1613 bool GLRenderer::isContextLost() | 1613 bool GLRenderer::isContextLost() |
1614 { | 1614 { |
1615 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1615 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1616 } | 1616 } |
1617 | 1617 |
1618 } // namespace cc | 1618 } // namespace cc |
OLD | NEW |