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/gl_renderer.h" | 5 #include "cc/gl_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 void GLRenderer::doNoOp() | 277 void GLRenderer::doNoOp() |
278 { | 278 { |
279 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 279 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
280 GLC(m_context, m_context->flush()); | 280 GLC(m_context, m_context->flush()); |
281 } | 281 } |
282 | 282 |
283 void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) | 283 void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) |
284 { | 284 { |
285 DCHECK(quad->rect.Contains(quad->visible_rect)); | 285 DCHECK(quad->rect.Contains(quad->visible_rect)); |
286 if (quad->material != DrawQuad::TEXTURE_CONTENT) { | 286 if (quad->material != DrawQuad::TEXTURE_CONTENT) { |
287 flushTextureQuadCache(); | 287 flushTextureQuadCache(); |
288 setBlendEnabled(quad->ShouldDrawWithBlending()); | |
289 } | 288 } |
290 | 289 |
291 switch (quad->material) { | 290 switch (quad->material) { |
292 case DrawQuad::INVALID: | 291 case DrawQuad::INVALID: |
293 NOTREACHED(); | 292 NOTREACHED(); |
294 break; | 293 break; |
295 case DrawQuad::CHECKERBOARD: | 294 case DrawQuad::CHECKERBOARD: |
296 drawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad)); | 295 drawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad)); |
297 break; | 296 break; |
298 case DrawQuad::DEBUG_BORDER: | 297 case DrawQuad::DEBUG_BORDER: |
(...skipping 18 matching lines...) Expand all Loading... |
317 drawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); | 316 drawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); |
318 break; | 317 break; |
319 case DrawQuad::YUV_VIDEO_CONTENT: | 318 case DrawQuad::YUV_VIDEO_CONTENT: |
320 drawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); | 319 drawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); |
321 break; | 320 break; |
322 } | 321 } |
323 } | 322 } |
324 | 323 |
325 void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const Checkerbo
ardDrawQuad* quad) | 324 void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const Checkerbo
ardDrawQuad* quad) |
326 { | 325 { |
| 326 setBlendEnabled(quad->ShouldDrawWithBlending()); |
| 327 |
327 const TileCheckerboardProgram* program = tileCheckerboardProgram(); | 328 const TileCheckerboardProgram* program = tileCheckerboardProgram(); |
328 DCHECK(program && (program->initialized() || isContextLost())); | 329 DCHECK(program && (program->initialized() || isContextLost())); |
329 setUseProgram(program->program()); | 330 setUseProgram(program->program()); |
330 | 331 |
331 SkColor color = quad->color; | 332 SkColor color = quad->color; |
332 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation(
), SkColorGetR(color) / 255.0, SkColorGetG(color) / 255.0, SkColorGetB(color) /
255.0, 1)); | 333 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation(
), SkColorGetR(color) / 255.0, SkColorGetG(color) / 255.0, SkColorGetB(color) /
255.0, 1)); |
333 | 334 |
334 const int checkerboardWidth = 16; | 335 const int checkerboardWidth = 16; |
335 float frequency = 1.0 / checkerboardWidth; | 336 float frequency = 1.0 / checkerboardWidth; |
336 | 337 |
337 gfx::Rect tileRect = quad->rect; | 338 gfx::Rect tileRect = quad->rect; |
338 float texOffsetX = tileRect.x() % checkerboardWidth; | 339 float texOffsetX = tileRect.x() % checkerboardWidth; |
339 float texOffsetY = tileRect.y() % checkerboardWidth; | 340 float texOffsetY = tileRect.y() % checkerboardWidth; |
340 float texScaleX = tileRect.width(); | 341 float texScaleX = tileRect.width(); |
341 float texScaleY = tileRect.height(); | 342 float texScaleY = tileRect.height(); |
342 GLC(context(), context()->uniform4f(program->fragmentShader().texTransformLo
cation(), texOffsetX, texOffsetY, texScaleX, texScaleY)); | 343 GLC(context(), context()->uniform4f(program->fragmentShader().texTransformLo
cation(), texOffsetX, texOffsetY, texScaleX, texScaleY)); |
343 | 344 |
344 GLC(context(), context()->uniform1f(program->fragmentShader().frequencyLocat
ion(), frequency)); | 345 GLC(context(), context()->uniform1f(program->fragmentShader().frequencyLocat
ion(), frequency)); |
345 | 346 |
346 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation())
; | 347 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation())
; |
347 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh
ader().matrixLocation()); | 348 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh
ader().matrixLocation()); |
348 } | 349 } |
349 | 350 |
350 void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde
rDrawQuad* quad) | 351 void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde
rDrawQuad* quad) |
351 { | 352 { |
| 353 setBlendEnabled(quad->ShouldDrawWithBlending()); |
| 354 |
352 static float glMatrix[16]; | 355 static float glMatrix[16]; |
353 const SolidColorProgram* program = solidColorProgram(); | 356 const SolidColorProgram* program = solidColorProgram(); |
354 DCHECK(program && (program->initialized() || isContextLost())); | 357 DCHECK(program && (program->initialized() || isContextLost())); |
355 setUseProgram(program->program()); | 358 setUseProgram(program->program()); |
356 | 359 |
357 // Use the full quadRect for debug quads to not move the edges based on part
ial swaps. | 360 // Use the full quadRect for debug quads to not move the edges based on part
ial swaps. |
358 const gfx::Rect& layerRect = quad->rect; | 361 const gfx::Rect& layerRect = quad->rect; |
359 gfx::Transform renderMatrix = quad->quadTransform(); | 362 gfx::Transform renderMatrix = quad->quadTransform(); |
360 renderMatrix.Translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerR
ect.height() + layerRect.y()); | 363 renderMatrix.Translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerR
ect.height() + layerRect.y()); |
361 renderMatrix.Scale(layerRect.width(), layerRect.height()); | 364 renderMatrix.Scale(layerRect.width(), layerRect.height()); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 | 548 |
546 useRenderPass(frame, targetRenderPass); | 549 useRenderPass(frame, targetRenderPass); |
547 | 550 |
548 if (!usingBackgroundTexture) | 551 if (!usingBackgroundTexture) |
549 return scoped_ptr<ScopedResource>(); | 552 return scoped_ptr<ScopedResource>(); |
550 return backgroundTexture.Pass(); | 553 return backgroundTexture.Pass(); |
551 } | 554 } |
552 | 555 |
553 void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
d* quad) | 556 void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
d* quad) |
554 { | 557 { |
| 558 setBlendEnabled(quad->ShouldDrawWithBlending()); |
| 559 |
555 CachedResource* contentsTexture = m_renderPassTextures.get(quad->render_pass
_id); | 560 CachedResource* contentsTexture = m_renderPassTextures.get(quad->render_pass
_id); |
556 if (!contentsTexture || !contentsTexture->id()) | 561 if (!contentsTexture || !contentsTexture->id()) |
557 return; | 562 return; |
558 | 563 |
559 gfx::Transform quadRectMatrix; | 564 gfx::Transform quadRectMatrix; |
560 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); | 565 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); |
561 gfx::Transform contentsDeviceTransform = frame.windowMatrix * frame.projecti
onMatrix * quadRectMatrix; | 566 gfx::Transform contentsDeviceTransform = frame.windowMatrix * frame.projecti
onMatrix * quadRectMatrix; |
562 contentsDeviceTransform.FlattenTo2d(); | 567 contentsDeviceTransform.FlattenTo2d(); |
563 | 568 |
564 // Can only draw surface if device matrix is invertible. | 569 // Can only draw surface if device matrix is invertible. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, shaderMatrixLocat
ion); | 719 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, shaderMatrixLocat
ion); |
715 | 720 |
716 // Flush the compositor context before the filter bitmap goes out of | 721 // Flush the compositor context before the filter bitmap goes out of |
717 // scope, so the draw gets processed before the filter texture gets deleted. | 722 // scope, so the draw gets processed before the filter texture gets deleted. |
718 if (filterBitmap.getTexture()) | 723 if (filterBitmap.getTexture()) |
719 m_context->flush(); | 724 m_context->flush(); |
720 } | 725 } |
721 | 726 |
722 void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorD
rawQuad* quad) | 727 void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorD
rawQuad* quad) |
723 { | 728 { |
| 729 setBlendEnabled(quad->ShouldDrawWithBlending()); |
| 730 |
724 const SolidColorProgram* program = solidColorProgram(); | 731 const SolidColorProgram* program = solidColorProgram(); |
725 setUseProgram(program->program()); | 732 setUseProgram(program->program()); |
726 | 733 |
727 SkColor color = quad->color; | 734 SkColor color = quad->color; |
728 float opacity = quad->opacity(); | 735 float opacity = quad->opacity(); |
729 float alpha = (SkColorGetA(color) / 255.0) * opacity; | 736 float alpha = (SkColorGetA(color) / 255.0) * opacity; |
730 | 737 |
731 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation(
), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, (
SkColorGetB(color) / 255.0) * alpha, alpha)); | 738 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation(
), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, (
SkColorGetB(color) / 255.0) * alpha, alpha)); |
732 | 739 |
733 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh
ader().matrixLocation()); | 740 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh
ader().matrixLocation()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 float vertexTexScaleX = tileRect.width() / clampGeomRect.width(); | 808 float vertexTexScaleX = tileRect.width() / clampGeomRect.width(); |
802 float vertexTexScaleY = tileRect.height() / clampGeomRect.height(); | 809 float vertexTexScaleY = tileRect.height() / clampGeomRect.height(); |
803 | 810 |
804 // Map to normalized texture coordinates. | 811 // Map to normalized texture coordinates. |
805 const gfx::Size& textureSize = quad->texture_size; | 812 const gfx::Size& textureSize = quad->texture_size; |
806 float fragmentTexTranslateX = clampTexRect.x() / textureSize.width(); | 813 float fragmentTexTranslateX = clampTexRect.x() / textureSize.width(); |
807 float fragmentTexTranslateY = clampTexRect.y() / textureSize.height(); | 814 float fragmentTexTranslateY = clampTexRect.y() / textureSize.height(); |
808 float fragmentTexScaleX = clampTexRect.width() / textureSize.width(); | 815 float fragmentTexScaleX = clampTexRect.width() / textureSize.width(); |
809 float fragmentTexScaleY = clampTexRect.height() / textureSize.height(); | 816 float fragmentTexScaleY = clampTexRect.height() / textureSize.height(); |
810 | 817 |
811 | |
812 gfx::QuadF localQuad; | 818 gfx::QuadF localQuad; |
813 gfx::Transform deviceTransform = frame.windowMatrix * frame.projectionMatrix
* quad->quadTransform(); | 819 gfx::Transform deviceTransform = frame.windowMatrix * frame.projectionMatrix
* quad->quadTransform(); |
814 deviceTransform.FlattenTo2d(); | 820 deviceTransform.FlattenTo2d(); |
815 if (!deviceTransform.IsInvertible()) | 821 if (!deviceTransform.IsInvertible()) |
816 return; | 822 return; |
817 | 823 |
818 bool clipped = false; | 824 bool clipped = false; |
819 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q
uad->visibleContentRect()), clipped); | 825 gfx::QuadF deviceLayerQuad = MathUtil::mapQuad(deviceTransform, gfx::QuadF(q
uad->visibleContentRect()), clipped); |
820 DCHECK(!clipped); | 826 DCHECK(!clipped); |
821 | 827 |
| 828 // TODO(reveman): Axis-aligned is not enough to avoid anti-aliasing. |
| 829 // Bounding rectangle for quad also needs to be expressible as |
| 830 // an integer rectangle. crbug.com/169374 |
| 831 bool isAxisAlignedInTarget = deviceLayerQuad.IsRectilinear(); |
| 832 bool useAA = !clipped && !isAxisAlignedInTarget && quad->IsEdge(); |
| 833 |
822 TileProgramUniforms uniforms; | 834 TileProgramUniforms uniforms; |
823 // For now, we simply skip anti-aliasing with the quad is clipped. This only
happens | 835 if (useAA) { |
824 // on perspective transformed layers that go partially behind the camera. | |
825 if (quad->IsAntialiased() && !clipped) { | |
826 if (quad->swizzle_contents) | 836 if (quad->swizzle_contents) |
827 tileUniformLocation(tileProgramSwizzleAA(), uniforms); | 837 tileUniformLocation(tileProgramSwizzleAA(), uniforms); |
828 else | 838 else |
829 tileUniformLocation(tileProgramAA(), uniforms); | 839 tileUniformLocation(tileProgramAA(), uniforms); |
830 } else { | 840 } else { |
831 if (quad->ShouldDrawWithBlending()) { | 841 if (quad->ShouldDrawWithBlending()) { |
832 if (quad->swizzle_contents) | 842 if (quad->swizzle_contents) |
833 tileUniformLocation(tileProgramSwizzle(), uniforms); | 843 tileUniformLocation(tileProgramSwizzle(), uniforms); |
834 else | 844 else |
835 tileUniformLocation(tileProgram(), uniforms); | 845 tileUniformLocation(tileProgram(), uniforms); |
836 } else { | 846 } else { |
837 if (quad->swizzle_contents) | 847 if (quad->swizzle_contents) |
838 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); | 848 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); |
839 else | 849 else |
840 tileUniformLocation(tileProgramOpaque(), uniforms); | 850 tileUniformLocation(tileProgramOpaque(), uniforms); |
841 } | 851 } |
842 } | 852 } |
843 | 853 |
844 setUseProgram(uniforms.program); | 854 setUseProgram(uniforms.program); |
845 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); | 855 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); |
846 bool scaled = (texToGeomScaleX != 1 || texToGeomScaleY != 1); | 856 bool scaled = (texToGeomScaleX != 1 || texToGeomScaleY != 1); |
847 GLenum filter = (quad->IsAntialiased() || scaled || !quad->quadTransform().I
sIdentityOrIntegerTranslation()) ? GL_LINEAR : GL_NEAREST; | 857 GLenum filter = (useAA || scaled || !quad->quadTransform().IsIdentityOrInteg
erTranslation()) ? GL_LINEAR : GL_NEAREST; |
848 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad-
>resource_id, GL_TEXTURE_2D, filter); | 858 ResourceProvider::ScopedSamplerGL quadResourceLock(m_resourceProvider, quad-
>resource_id, GL_TEXTURE_2D, filter); |
849 | 859 |
850 bool useAA = !clipped && quad->IsAntialiased(); | |
851 if (useAA) { | 860 if (useAA) { |
852 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound
ingBox())); | 861 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound
ingBox())); |
853 deviceLayerBounds.inflateAntiAliasingDistance(); | 862 deviceLayerBounds.inflateAntiAliasingDistance(); |
854 | 863 |
855 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); | 864 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); |
856 deviceLayerEdges.inflateAntiAliasingDistance(); | 865 deviceLayerEdges.inflateAntiAliasingDistance(); |
857 | 866 |
858 float edge[24]; | 867 float edge[24]; |
859 deviceLayerEdges.toFloatArray(edge); | 868 deviceLayerEdges.toFloatArray(edge); |
860 deviceLayerBounds.toFloatArray(&edge[12]); | 869 deviceLayerBounds.toFloatArray(&edge[12]); |
(...skipping 16 matching lines...) Expand all Loading... |
877 DCHECK(!clipped); | 886 DCHECK(!clipped); |
878 topRight = MathUtil::mapPoint(deviceTransform, topRight, clipped); | 887 topRight = MathUtil::mapPoint(deviceTransform, topRight, clipped); |
879 DCHECK(!clipped); | 888 DCHECK(!clipped); |
880 | 889 |
881 LayerQuad::Edge bottomEdge(bottomRight, bottomLeft); | 890 LayerQuad::Edge bottomEdge(bottomRight, bottomLeft); |
882 LayerQuad::Edge leftEdge(bottomLeft, topLeft); | 891 LayerQuad::Edge leftEdge(bottomLeft, topLeft); |
883 LayerQuad::Edge topEdge(topLeft, topRight); | 892 LayerQuad::Edge topEdge(topLeft, topRight); |
884 LayerQuad::Edge rightEdge(topRight, bottomRight); | 893 LayerQuad::Edge rightEdge(topRight, bottomRight); |
885 | 894 |
886 // Only apply anti-aliasing to edges not clipped by culling or scissorin
g. | 895 // Only apply anti-aliasing to edges not clipped by culling or scissorin
g. |
887 if (quad->top_edge_aa && tileRect.y() == quad->rect.y()) | 896 if (quad->IsTopEdge() && tileRect.y() == quad->rect.y()) |
888 topEdge = deviceLayerEdges.top(); | 897 topEdge = deviceLayerEdges.top(); |
889 if (quad->left_edge_aa && tileRect.x() == quad->rect.x()) | 898 if (quad->IsLeftEdge() && tileRect.x() == quad->rect.x()) |
890 leftEdge = deviceLayerEdges.left(); | 899 leftEdge = deviceLayerEdges.left(); |
891 if (quad->right_edge_aa && tileRect.right() == quad->rect.right()) | 900 if (quad->IsRightEdge() && tileRect.right() == quad->rect.right()) |
892 rightEdge = deviceLayerEdges.right(); | 901 rightEdge = deviceLayerEdges.right(); |
893 if (quad->bottom_edge_aa && tileRect.bottom() == quad->rect.bottom()) | 902 if (quad->IsBottomEdge() && tileRect.bottom() == quad->rect.bottom()) |
894 bottomEdge = deviceLayerEdges.bottom(); | 903 bottomEdge = deviceLayerEdges.bottom(); |
895 | 904 |
896 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; | 905 float sign = gfx::QuadF(tileRect).IsCounterClockwise() ? -1 : 1; |
897 bottomEdge.scale(sign); | 906 bottomEdge.scale(sign); |
898 leftEdge.scale(sign); | 907 leftEdge.scale(sign); |
899 topEdge.scale(sign); | 908 topEdge.scale(sign); |
900 rightEdge.scale(sign); | 909 rightEdge.scale(sign); |
901 | 910 |
902 // Create device space quad. | 911 // Create device space quad. |
903 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); | 912 LayerQuad deviceQuad(leftEdge, topEdge, rightEdge, bottomEdge); |
(...skipping 17 matching lines...) Expand all Loading... |
921 vertexTexTranslateX *= fragmentTexScaleX; | 930 vertexTexTranslateX *= fragmentTexScaleX; |
922 vertexTexTranslateY *= fragmentTexScaleY; | 931 vertexTexTranslateY *= fragmentTexScaleY; |
923 vertexTexTranslateX += fragmentTexTranslateX; | 932 vertexTexTranslateX += fragmentTexTranslateX; |
924 vertexTexTranslateY += fragmentTexTranslateY; | 933 vertexTexTranslateY += fragmentTexTranslateY; |
925 | 934 |
926 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation,
vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); | 935 GLC(context(), context()->uniform4f(uniforms.vertexTexTransformLocation,
vertexTexTranslateX, vertexTexTranslateY, vertexTexScaleX, vertexTexScaleY)); |
927 | 936 |
928 localQuad = gfx::RectF(tileRect); | 937 localQuad = gfx::RectF(tileRect); |
929 } | 938 } |
930 | 939 |
| 940 // Enable blending when the quad properties require it or if we decided |
| 941 // to use antialiasing. |
| 942 setBlendEnabled(quad->ShouldDrawWithBlending() || useAA); |
| 943 |
931 // Normalize to tileRect. | 944 // Normalize to tileRect. |
932 localQuad.Scale(1.0f / tileRect.width(), 1.0f / tileRect.height()); | 945 localQuad.Scale(1.0f / tileRect.width(), 1.0f / tileRect.height()); |
933 | 946 |
934 setShaderOpacity(quad->opacity(), uniforms.alphaLocation); | 947 setShaderOpacity(quad->opacity(), uniforms.alphaLocation); |
935 setShaderQuadF(localQuad, uniforms.pointLocation); | 948 setShaderQuadF(localQuad, uniforms.pointLocation); |
936 | 949 |
937 // The tile quad shader behaves differently compared to all other shaders. | 950 // The tile quad shader behaves differently compared to all other shaders. |
938 // The transform and vertex data are used to figure out the extents that the | 951 // The transform and vertex data are used to figure out the extents that the |
939 // un-antialiased quad should have and which vertex this is and the float | 952 // un-antialiased quad should have and which vertex this is and the float |
940 // quad passed in via uniform is the actual geometry that gets used to draw | 953 // quad passed in via uniform is the actual geometry that gets used to draw |
941 // it. This is why this centered rect is used and not the original quadRect. | 954 // it. This is why this centered rect is used and not the original quadRect. |
942 gfx::RectF centeredRect(gfx::PointF(-0.5 * tileRect.width(), -0.5 * tileRect
.height()), tileRect.size()); | 955 gfx::RectF centeredRect(gfx::PointF(-0.5 * tileRect.width(), -0.5 * tileRect
.height()), tileRect.size()); |
943 drawQuadGeometry(frame, quad->quadTransform(), centeredRect, uniforms.matrix
Location); | 956 drawQuadGeometry(frame, quad->quadTransform(), centeredRect, uniforms.matrix
Location); |
944 } | 957 } |
945 | 958 |
946 void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQ
uad* quad) | 959 void GLRenderer::drawYUVVideoQuad(const DrawingFrame& frame, const YUVVideoDrawQ
uad* quad) |
947 { | 960 { |
| 961 setBlendEnabled(quad->ShouldDrawWithBlending()); |
| 962 |
948 const VideoYUVProgram* program = videoYUVProgram(); | 963 const VideoYUVProgram* program = videoYUVProgram(); |
949 DCHECK(program && (program->initialized() || isContextLost())); | 964 DCHECK(program && (program->initialized() || isContextLost())); |
950 | 965 |
951 const VideoLayerImpl::FramePlane& yPlane = quad->y_plane; | 966 const VideoLayerImpl::FramePlane& yPlane = quad->y_plane; |
952 const VideoLayerImpl::FramePlane& uPlane = quad->u_plane; | 967 const VideoLayerImpl::FramePlane& uPlane = quad->u_plane; |
953 const VideoLayerImpl::FramePlane& vPlane = quad->v_plane; | 968 const VideoLayerImpl::FramePlane& vPlane = quad->v_plane; |
954 | 969 |
955 GLC(context(), context()->activeTexture(GL_TEXTURE1)); | 970 GLC(context(), context()->activeTexture(GL_TEXTURE1)); |
956 ResourceProvider::ScopedSamplerGL yPlaneLock(m_resourceProvider, yPlane.reso
urceId, GL_TEXTURE_2D, GL_LINEAR); | 971 ResourceProvider::ScopedSamplerGL yPlaneLock(m_resourceProvider, yPlane.reso
urceId, GL_TEXTURE_2D, GL_LINEAR); |
957 GLC(context(), context()->activeTexture(GL_TEXTURE2)); | 972 GLC(context(), context()->activeTexture(GL_TEXTURE2)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 | 1005 |
991 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation())
; | 1006 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation())
; |
992 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh
ader().matrixLocation()); | 1007 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh
ader().matrixLocation()); |
993 | 1008 |
994 // Reset active texture back to texture 0. | 1009 // Reset active texture back to texture 0. |
995 GLC(context(), context()->activeTexture(GL_TEXTURE0)); | 1010 GLC(context(), context()->activeTexture(GL_TEXTURE0)); |
996 } | 1011 } |
997 | 1012 |
998 void GLRenderer::drawStreamVideoQuad(const DrawingFrame& frame, const StreamVide
oDrawQuad* quad) | 1013 void GLRenderer::drawStreamVideoQuad(const DrawingFrame& frame, const StreamVide
oDrawQuad* quad) |
999 { | 1014 { |
| 1015 setBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1016 |
1000 static float glMatrix[16]; | 1017 static float glMatrix[16]; |
1001 | 1018 |
1002 DCHECK(m_capabilities.usingEglImage); | 1019 DCHECK(m_capabilities.usingEglImage); |
1003 | 1020 |
1004 const VideoStreamTextureProgram* program = videoStreamTextureProgram(); | 1021 const VideoStreamTextureProgram* program = videoStreamTextureProgram(); |
1005 setUseProgram(program->program()); | 1022 setUseProgram(program->program()); |
1006 | 1023 |
1007 toGLMatrix(&glMatrix[0], quad->matrix); | 1024 toGLMatrix(&glMatrix[0], quad->matrix); |
1008 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().texMatrix
Location(), 1, false, glMatrix)); | 1025 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().texMatrix
Location(), 1, false, glMatrix)); |
1009 | 1026 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 } | 1195 } |
1179 | 1196 |
1180 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, binding.matrixLoc
ation); | 1197 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, binding.matrixLoc
ation); |
1181 | 1198 |
1182 if (!quad->premultiplied_alpha) | 1199 if (!quad->premultiplied_alpha) |
1183 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 1200 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
1184 } | 1201 } |
1185 | 1202 |
1186 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra
wQuad* quad) | 1203 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra
wQuad* quad) |
1187 { | 1204 { |
| 1205 setBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1206 |
1188 TexTransformTextureProgramBinding binding; | 1207 TexTransformTextureProgramBinding binding; |
1189 binding.set(textureIOSurfaceProgram(), context()); | 1208 binding.set(textureIOSurfaceProgram(), context()); |
1190 | 1209 |
1191 setUseProgram(binding.programId); | 1210 setUseProgram(binding.programId); |
1192 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); | 1211 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); |
1193 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) | 1212 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) |
1194 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua
d->io_surface_size.height(), quad->io_surface_size.width(), quad->io_surface_siz
e.height() * -1.0)); | 1213 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, qua
d->io_surface_size.height(), quad->io_surface_size.width(), quad->io_surface_siz
e.height() * -1.0)); |
1195 else | 1214 else |
1196 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0,
quad->io_surface_size.width(), quad->io_surface_size.height())); | 1215 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0,
quad->io_surface_size.width(), quad->io_surface_size.height())); |
1197 | 1216 |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 | 1866 |
1848 releaseRenderPassTextures(); | 1867 releaseRenderPassTextures(); |
1849 } | 1868 } |
1850 | 1869 |
1851 bool GLRenderer::isContextLost() | 1870 bool GLRenderer::isContextLost() |
1852 { | 1871 { |
1853 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1872 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1854 } | 1873 } |
1855 | 1874 |
1856 } // namespace cc | 1875 } // namespace cc |
OLD | NEW |