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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 makeContextCurrent(); | 236 makeContextCurrent(); |
237 // Bind the common vertex attributes used for drawing all the layers. | 237 // Bind the common vertex attributes used for drawing all the layers. |
238 m_sharedGeometry->prepareForDraw(); | 238 m_sharedGeometry->prepareForDraw(); |
239 | 239 |
240 GLC(m_context, m_context->disable(GL_DEPTH_TEST)); | 240 GLC(m_context, m_context->disable(GL_DEPTH_TEST)); |
241 GLC(m_context, m_context->disable(GL_CULL_FACE)); | 241 GLC(m_context, m_context->disable(GL_CULL_FACE)); |
242 GLC(m_context, m_context->colorMask(true, true, true, true)); | 242 GLC(m_context, m_context->colorMask(true, true, true, true)); |
243 GLC(m_context, m_context->enable(GL_BLEND)); | 243 GLC(m_context, m_context->enable(GL_BLEND)); |
244 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 244 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
245 GLC(context(), context()->activeTexture(GL_TEXTURE0)); | 245 GLC(context(), context()->activeTexture(GL_TEXTURE0)); |
246 m_blendShadow = true; | |
jamesr
2012/11/29 11:17:11
nit: could you move this right next to the enable(
whunt
2012/11/29 23:55:06
Done.
On 2012/11/29 11:17:11, jamesr wrote:
| |
247 m_programShadow = 0; | |
246 } | 248 } |
247 | 249 |
248 void GLRenderer::doNoOp() | 250 void GLRenderer::doNoOp() |
249 { | 251 { |
250 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0)); | 252 GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0)); |
251 GLC(m_context, m_context->flush()); | 253 GLC(m_context, m_context->flush()); |
252 } | 254 } |
253 | 255 |
254 void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) | 256 void GLRenderer::drawQuad(DrawingFrame& frame, const DrawQuad* quad) |
255 { | 257 { |
256 DCHECK(quad->rect.Contains(quad->visible_rect)); | 258 DCHECK(quad->rect.Contains(quad->visible_rect)); |
257 | 259 if (quad->material != DrawQuad::TEXTURE_CONTENT) |
258 if (quad->ShouldDrawWithBlending()) | 260 { |
259 GLC(m_context, m_context->enable(GL_BLEND)); | 261 flushTextureQuadCache(); |
260 else | 262 setBlendEnabled(quad->ShouldDrawWithBlending()); |
261 GLC(m_context, m_context->disable(GL_BLEND)); | 263 } |
262 | 264 |
263 switch (quad->material) { | 265 switch (quad->material) { |
264 case DrawQuad::INVALID: | 266 case DrawQuad::INVALID: |
265 NOTREACHED(); | 267 NOTREACHED(); |
266 break; | 268 break; |
267 case DrawQuad::CHECKERBOARD: | 269 case DrawQuad::CHECKERBOARD: |
268 drawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad)); | 270 drawCheckerboardQuad(frame, CheckerboardDrawQuad::MaterialCast(quad)); |
269 break; | 271 break; |
270 case DrawQuad::DEBUG_BORDER: | 272 case DrawQuad::DEBUG_BORDER: |
271 drawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad)); | 273 drawDebugBorderQuad(frame, DebugBorderDrawQuad::MaterialCast(quad)); |
272 break; | 274 break; |
273 case DrawQuad::IO_SURFACE_CONTENT: | 275 case DrawQuad::IO_SURFACE_CONTENT: |
274 drawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad)); | 276 drawIOSurfaceQuad(frame, IOSurfaceDrawQuad::MaterialCast(quad)); |
275 break; | 277 break; |
276 case DrawQuad::RENDER_PASS: | 278 case DrawQuad::RENDER_PASS: |
277 drawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad)); | 279 drawRenderPassQuad(frame, RenderPassDrawQuad::MaterialCast(quad)); |
278 break; | 280 break; |
279 case DrawQuad::SOLID_COLOR: | 281 case DrawQuad::SOLID_COLOR: |
280 drawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad)); | 282 drawSolidColorQuad(frame, SolidColorDrawQuad::MaterialCast(quad)); |
281 break; | 283 break; |
282 case DrawQuad::STREAM_VIDEO_CONTENT: | 284 case DrawQuad::STREAM_VIDEO_CONTENT: |
283 drawStreamVideoQuad(frame, StreamVideoDrawQuad::MaterialCast(quad)); | 285 drawStreamVideoQuad(frame, StreamVideoDrawQuad::MaterialCast(quad)); |
284 break; | 286 break; |
285 case DrawQuad::TEXTURE_CONTENT: | 287 case DrawQuad::TEXTURE_CONTENT: |
286 drawTextureQuad(frame, TextureDrawQuad::MaterialCast(quad)); | 288 enqueueTextureQuad(frame, TextureDrawQuad::MaterialCast(quad)); |
287 break; | 289 break; |
288 case DrawQuad::TILED_CONTENT: | 290 case DrawQuad::TILED_CONTENT: |
289 drawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); | 291 drawTileQuad(frame, TileDrawQuad::MaterialCast(quad)); |
290 break; | 292 break; |
291 case DrawQuad::YUV_VIDEO_CONTENT: | 293 case DrawQuad::YUV_VIDEO_CONTENT: |
292 drawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); | 294 drawYUVVideoQuad(frame, YUVVideoDrawQuad::MaterialCast(quad)); |
293 break; | 295 break; |
294 } | 296 } |
295 } | 297 } |
296 | 298 |
297 void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const Checkerbo ardDrawQuad* quad) | 299 void GLRenderer::drawCheckerboardQuad(const DrawingFrame& frame, const Checkerbo ardDrawQuad* quad) |
298 { | 300 { |
299 const TileCheckerboardProgram* program = tileCheckerboardProgram(); | 301 const TileCheckerboardProgram* program = tileCheckerboardProgram(); |
300 DCHECK(program && (program->initialized() || isContextLost())); | 302 DCHECK(program && (program->initialized() || isContextLost())); |
301 GLC(context(), context()->useProgram(program->program())); | 303 setUseProgram(program->program()); |
302 | 304 |
303 SkColor color = quad->color; | 305 SkColor color = quad->color; |
304 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), SkColorGetR(color) / 255.0, SkColorGetG(color) / 255.0, SkColorGetB(color) / 255.0, 1)); | 306 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), SkColorGetR(color) / 255.0, SkColorGetG(color) / 255.0, SkColorGetB(color) / 255.0, 1)); |
305 | 307 |
306 const int checkerboardWidth = 16; | 308 const int checkerboardWidth = 16; |
307 float frequency = 1.0 / checkerboardWidth; | 309 float frequency = 1.0 / checkerboardWidth; |
308 | 310 |
309 gfx::Rect tileRect = quad->rect; | 311 gfx::Rect tileRect = quad->rect; |
310 float texOffsetX = tileRect.x() % checkerboardWidth; | 312 float texOffsetX = tileRect.x() % checkerboardWidth; |
311 float texOffsetY = tileRect.y() % checkerboardWidth; | 313 float texOffsetY = tileRect.y() % checkerboardWidth; |
312 float texScaleX = tileRect.width(); | 314 float texScaleX = tileRect.width(); |
313 float texScaleY = tileRect.height(); | 315 float texScaleY = tileRect.height(); |
314 GLC(context(), context()->uniform4f(program->fragmentShader().texTransformLo cation(), texOffsetX, texOffsetY, texScaleX, texScaleY)); | 316 GLC(context(), context()->uniform4f(program->fragmentShader().texTransformLo cation(), texOffsetX, texOffsetY, texScaleX, texScaleY)); |
315 | 317 |
316 GLC(context(), context()->uniform1f(program->fragmentShader().frequencyLocat ion(), frequency)); | 318 GLC(context(), context()->uniform1f(program->fragmentShader().frequencyLocat ion(), frequency)); |
317 | 319 |
318 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ; | 320 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ; |
319 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh ader().matrixLocation()); | 321 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh ader().matrixLocation()); |
320 } | 322 } |
321 | 323 |
322 void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde rDrawQuad* quad) | 324 void GLRenderer::drawDebugBorderQuad(const DrawingFrame& frame, const DebugBorde rDrawQuad* quad) |
323 { | 325 { |
324 static float glMatrix[16]; | 326 static float glMatrix[16]; |
325 const SolidColorProgram* program = solidColorProgram(); | 327 const SolidColorProgram* program = solidColorProgram(); |
326 DCHECK(program && (program->initialized() || isContextLost())); | 328 DCHECK(program && (program->initialized() || isContextLost())); |
327 GLC(context(), context()->useProgram(program->program())); | 329 setUseProgram(program->program()); |
328 | 330 |
329 // Use the full quadRect for debug quads to not move the edges based on part ial swaps. | 331 // Use the full quadRect for debug quads to not move the edges based on part ial swaps. |
330 const gfx::Rect& layerRect = quad->rect; | 332 const gfx::Rect& layerRect = quad->rect; |
331 gfx::Transform renderMatrix = quad->quadTransform(); | 333 gfx::Transform renderMatrix = quad->quadTransform(); |
332 renderMatrix.Translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerR ect.height() + layerRect.y()); | 334 renderMatrix.Translate(0.5 * layerRect.width() + layerRect.x(), 0.5 * layerR ect.height() + layerRect.y()); |
333 renderMatrix.Scale(layerRect.width(), layerRect.height()); | 335 renderMatrix.Scale(layerRect.width(), layerRect.height()); |
334 GLRenderer::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix); | 336 GLRenderer::toGLMatrix(&glMatrix[0], frame.projectionMatrix * renderMatrix); |
335 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().matrixLoc ation(), 1, false, &glMatrix[0])); | 337 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().matrixLoc ation(), 1, false, &glMatrix[0])); |
336 | 338 |
337 SkColor color = quad->color; | 339 SkColor color = quad->color; |
338 float alpha = SkColorGetA(color) / 255.0; | 340 float alpha = SkColorGetA(color) / 255.0; |
339 | 341 |
340 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha)); | 342 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha)); |
341 | 343 |
342 GLC(context(), context()->lineWidth(quad->width)); | 344 GLC(context(), context()->lineWidth(quad->width)); |
343 | 345 |
344 // The indices for the line are stored in the same array as the triangle ind ices. | 346 // The indices for the line are stored in the same array as the triangle ind ices. |
345 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 6 * sizeof(unsigned short))); | 347 GLC(context(), context()->drawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0 )); |
346 } | 348 } |
347 | 349 |
348 static WebGraphicsContext3D* getFilterContext(bool hasImplThread) | 350 static WebGraphicsContext3D* getFilterContext(bool hasImplThread) |
349 { | 351 { |
350 if (hasImplThread) | 352 if (hasImplThread) |
351 return WebSharedGraphicsContext3D::compositorThreadContext(); | 353 return WebSharedGraphicsContext3D::compositorThreadContext(); |
352 else | 354 else |
353 return WebSharedGraphicsContext3D::mainThreadContext(); | 355 return WebSharedGraphicsContext3D::mainThreadContext(); |
354 } | 356 } |
355 | 357 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 | 582 |
581 int shaderQuadLocation = -1; | 583 int shaderQuadLocation = -1; |
582 int shaderEdgeLocation = -1; | 584 int shaderEdgeLocation = -1; |
583 int shaderMaskSamplerLocation = -1; | 585 int shaderMaskSamplerLocation = -1; |
584 int shaderMaskTexCoordScaleLocation = -1; | 586 int shaderMaskTexCoordScaleLocation = -1; |
585 int shaderMaskTexCoordOffsetLocation = -1; | 587 int shaderMaskTexCoordOffsetLocation = -1; |
586 int shaderMatrixLocation = -1; | 588 int shaderMatrixLocation = -1; |
587 int shaderAlphaLocation = -1; | 589 int shaderAlphaLocation = -1; |
588 if (useAA && maskTextureId) { | 590 if (useAA && maskTextureId) { |
589 const RenderPassMaskProgramAA* program = renderPassMaskProgramAA(); | 591 const RenderPassMaskProgramAA* program = renderPassMaskProgramAA(); |
590 GLC(context(), context()->useProgram(program->program())); | 592 setUseProgram(program->program()); |
591 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); | 593 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); |
592 | 594 |
593 shaderQuadLocation = program->vertexShader().pointLocation(); | 595 shaderQuadLocation = program->vertexShader().pointLocation(); |
594 shaderEdgeLocation = program->fragmentShader().edgeLocation(); | 596 shaderEdgeLocation = program->fragmentShader().edgeLocation(); |
595 shaderMaskSamplerLocation = program->fragmentShader().maskSamplerLocatio n(); | 597 shaderMaskSamplerLocation = program->fragmentShader().maskSamplerLocatio n(); |
596 shaderMaskTexCoordScaleLocation = program->fragmentShader().maskTexCoord ScaleLocation(); | 598 shaderMaskTexCoordScaleLocation = program->fragmentShader().maskTexCoord ScaleLocation(); |
597 shaderMaskTexCoordOffsetLocation = program->fragmentShader().maskTexCoor dOffsetLocation(); | 599 shaderMaskTexCoordOffsetLocation = program->fragmentShader().maskTexCoor dOffsetLocation(); |
598 shaderMatrixLocation = program->vertexShader().matrixLocation(); | 600 shaderMatrixLocation = program->vertexShader().matrixLocation(); |
599 shaderAlphaLocation = program->fragmentShader().alphaLocation(); | 601 shaderAlphaLocation = program->fragmentShader().alphaLocation(); |
600 } else if (!useAA && maskTextureId) { | 602 } else if (!useAA && maskTextureId) { |
601 const RenderPassMaskProgram* program = renderPassMaskProgram(); | 603 const RenderPassMaskProgram* program = renderPassMaskProgram(); |
602 GLC(context(), context()->useProgram(program->program())); | 604 setUseProgram(program->program()); |
603 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); | 605 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); |
604 | 606 |
605 shaderMaskSamplerLocation = program->fragmentShader().maskSamplerLocatio n(); | 607 shaderMaskSamplerLocation = program->fragmentShader().maskSamplerLocatio n(); |
606 shaderMaskTexCoordScaleLocation = program->fragmentShader().maskTexCoord ScaleLocation(); | 608 shaderMaskTexCoordScaleLocation = program->fragmentShader().maskTexCoord ScaleLocation(); |
607 shaderMaskTexCoordOffsetLocation = program->fragmentShader().maskTexCoor dOffsetLocation(); | 609 shaderMaskTexCoordOffsetLocation = program->fragmentShader().maskTexCoor dOffsetLocation(); |
608 shaderMatrixLocation = program->vertexShader().matrixLocation(); | 610 shaderMatrixLocation = program->vertexShader().matrixLocation(); |
609 shaderAlphaLocation = program->fragmentShader().alphaLocation(); | 611 shaderAlphaLocation = program->fragmentShader().alphaLocation(); |
610 } else if (useAA && !maskTextureId) { | 612 } else if (useAA && !maskTextureId) { |
611 const RenderPassProgramAA* program = renderPassProgramAA(); | 613 const RenderPassProgramAA* program = renderPassProgramAA(); |
612 GLC(context(), context()->useProgram(program->program())); | 614 setUseProgram(program->program()); |
613 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); | 615 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); |
614 | 616 |
615 shaderQuadLocation = program->vertexShader().pointLocation(); | 617 shaderQuadLocation = program->vertexShader().pointLocation(); |
616 shaderEdgeLocation = program->fragmentShader().edgeLocation(); | 618 shaderEdgeLocation = program->fragmentShader().edgeLocation(); |
617 shaderMatrixLocation = program->vertexShader().matrixLocation(); | 619 shaderMatrixLocation = program->vertexShader().matrixLocation(); |
618 shaderAlphaLocation = program->fragmentShader().alphaLocation(); | 620 shaderAlphaLocation = program->fragmentShader().alphaLocation(); |
619 } else { | 621 } else { |
620 const RenderPassProgram* program = renderPassProgram(); | 622 const RenderPassProgram* program = renderPassProgram(); |
621 GLC(context(), context()->useProgram(program->program())); | 623 setUseProgram(program->program()); |
622 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); | 624 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLoc ation(), 0)); |
623 | 625 |
624 shaderMatrixLocation = program->vertexShader().matrixLocation(); | 626 shaderMatrixLocation = program->vertexShader().matrixLocation(); |
625 shaderAlphaLocation = program->fragmentShader().alphaLocation(); | 627 shaderAlphaLocation = program->fragmentShader().alphaLocation(); |
626 } | 628 } |
627 | 629 |
628 if (shaderMaskSamplerLocation != -1) { | 630 if (shaderMaskSamplerLocation != -1) { |
629 DCHECK(shaderMaskTexCoordScaleLocation != 1); | 631 DCHECK(shaderMaskTexCoordScaleLocation != 1); |
630 DCHECK(shaderMaskTexCoordOffsetLocation != 1); | 632 DCHECK(shaderMaskTexCoordOffsetLocation != 1); |
631 GLC(context(), context()->activeTexture(GL_TEXTURE1)); | 633 GLC(context(), context()->activeTexture(GL_TEXTURE1)); |
(...skipping 21 matching lines...) Expand all Loading... | |
653 | 655 |
654 // Flush the compositor context before the filter bitmap goes out of | 656 // Flush the compositor context before the filter bitmap goes out of |
655 // scope, so the draw gets processed before the filter texture gets deleted. | 657 // scope, so the draw gets processed before the filter texture gets deleted. |
656 if (filterBitmap.getTexture()) | 658 if (filterBitmap.getTexture()) |
657 m_context->flush(); | 659 m_context->flush(); |
658 } | 660 } |
659 | 661 |
660 void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorD rawQuad* quad) | 662 void GLRenderer::drawSolidColorQuad(const DrawingFrame& frame, const SolidColorD rawQuad* quad) |
661 { | 663 { |
662 const SolidColorProgram* program = solidColorProgram(); | 664 const SolidColorProgram* program = solidColorProgram(); |
663 GLC(context(), context()->useProgram(program->program())); | 665 setUseProgram(program->program()); |
664 | 666 |
665 SkColor color = quad->color; | 667 SkColor color = quad->color; |
666 float opacity = quad->opacity(); | 668 float opacity = quad->opacity(); |
667 float alpha = (SkColorGetA(color) / 255.0) * opacity; | 669 float alpha = (SkColorGetA(color) / 255.0) * opacity; |
668 | 670 |
669 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha)); | 671 GLC(context(), context()->uniform4f(program->fragmentShader().colorLocation( ), (SkColorGetR(color) / 255.0) * alpha, (SkColorGetG(color) / 255.0) * alpha, ( SkColorGetB(color) / 255.0) * alpha, alpha)); |
670 | 672 |
671 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh ader().matrixLocation()); | 673 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh ader().matrixLocation()); |
672 } | 674 } |
673 | 675 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 else | 773 else |
772 tileUniformLocation(tileProgram(), uniforms); | 774 tileUniformLocation(tileProgram(), uniforms); |
773 } else { | 775 } else { |
774 if (quad->swizzle_contents) | 776 if (quad->swizzle_contents) |
775 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); | 777 tileUniformLocation(tileProgramSwizzleOpaque(), uniforms); |
776 else | 778 else |
777 tileUniformLocation(tileProgramOpaque(), uniforms); | 779 tileUniformLocation(tileProgramOpaque(), uniforms); |
778 } | 780 } |
779 } | 781 } |
780 | 782 |
781 GLC(context(), context()->useProgram(uniforms.program)); | 783 setUseProgram(uniforms.program); |
782 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); | 784 GLC(context(), context()->uniform1i(uniforms.samplerLocation, 0)); |
783 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad ->resource_id); | 785 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad ->resource_id); |
784 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur eId())); | 786 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur eId())); |
785 | 787 |
786 bool useAA = !clipped && quad->IsAntialiased(); | 788 bool useAA = !clipped && quad->IsAntialiased(); |
787 if (useAA) { | 789 if (useAA) { |
788 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound ingBox())); | 790 LayerQuad deviceLayerBounds = LayerQuad(gfx::QuadF(deviceLayerQuad.Bound ingBox())); |
789 deviceLayerBounds.inflateAntiAliasingDistance(); | 791 deviceLayerBounds.inflateAntiAliasingDistance(); |
790 | 792 |
791 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); | 793 LayerQuad deviceLayerEdges = LayerQuad(deviceLayerQuad); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
888 ResourceProvider::ScopedReadLockGL yPlaneLock(m_resourceProvider, yPlane.res ourceId); | 890 ResourceProvider::ScopedReadLockGL yPlaneLock(m_resourceProvider, yPlane.res ourceId); |
889 ResourceProvider::ScopedReadLockGL uPlaneLock(m_resourceProvider, uPlane.res ourceId); | 891 ResourceProvider::ScopedReadLockGL uPlaneLock(m_resourceProvider, uPlane.res ourceId); |
890 ResourceProvider::ScopedReadLockGL vPlaneLock(m_resourceProvider, vPlane.res ourceId); | 892 ResourceProvider::ScopedReadLockGL vPlaneLock(m_resourceProvider, vPlane.res ourceId); |
891 GLC(context(), context()->activeTexture(GL_TEXTURE1)); | 893 GLC(context(), context()->activeTexture(GL_TEXTURE1)); |
892 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, yPlaneLock.textureId()) ); | 894 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, yPlaneLock.textureId()) ); |
893 GLC(context(), context()->activeTexture(GL_TEXTURE2)); | 895 GLC(context(), context()->activeTexture(GL_TEXTURE2)); |
894 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, uPlaneLock.textureId()) ); | 896 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, uPlaneLock.textureId()) ); |
895 GLC(context(), context()->activeTexture(GL_TEXTURE3)); | 897 GLC(context(), context()->activeTexture(GL_TEXTURE3)); |
896 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, vPlaneLock.textureId()) ); | 898 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, vPlaneLock.textureId()) ); |
897 | 899 |
898 GLC(context(), context()->useProgram(program->program())); | 900 setUseProgram(program->program()); |
899 | 901 |
900 GLC(context(), context()->uniform2f(program->vertexShader().texScaleLocation (), quad->tex_scale.width(), quad->tex_scale.height())); | 902 GLC(context(), context()->uniform2f(program->vertexShader().texScaleLocation (), quad->tex_scale.width(), quad->tex_scale.height())); |
901 GLC(context(), context()->uniform1i(program->fragmentShader().yTextureLocati on(), 1)); | 903 GLC(context(), context()->uniform1i(program->fragmentShader().yTextureLocati on(), 1)); |
902 GLC(context(), context()->uniform1i(program->fragmentShader().uTextureLocati on(), 2)); | 904 GLC(context(), context()->uniform1i(program->fragmentShader().uTextureLocati on(), 2)); |
903 GLC(context(), context()->uniform1i(program->fragmentShader().vTextureLocati on(), 3)); | 905 GLC(context(), context()->uniform1i(program->fragmentShader().vTextureLocati on(), 3)); |
904 | 906 |
905 // These values are magic numbers that are used in the transformation from Y UV to RGB color values. | 907 // These values are magic numbers that are used in the transformation from Y UV to RGB color values. |
906 // They are taken from the following webpage: http://www.fourcc.org/fccyvrgb .php | 908 // They are taken from the following webpage: http://www.fourcc.org/fccyvrgb .php |
907 float yuv2RGB[9] = { | 909 float yuv2RGB[9] = { |
908 1.164f, 1.164f, 1.164f, | 910 1.164f, 1.164f, 1.164f, |
(...skipping 22 matching lines...) Expand all Loading... | |
931 GLC(context(), context()->activeTexture(GL_TEXTURE0)); | 933 GLC(context(), context()->activeTexture(GL_TEXTURE0)); |
932 } | 934 } |
933 | 935 |
934 void GLRenderer::drawStreamVideoQuad(const DrawingFrame& frame, const StreamVide oDrawQuad* quad) | 936 void GLRenderer::drawStreamVideoQuad(const DrawingFrame& frame, const StreamVide oDrawQuad* quad) |
935 { | 937 { |
936 static float glMatrix[16]; | 938 static float glMatrix[16]; |
937 | 939 |
938 DCHECK(m_capabilities.usingEglImage); | 940 DCHECK(m_capabilities.usingEglImage); |
939 | 941 |
940 const VideoStreamTextureProgram* program = videoStreamTextureProgram(); | 942 const VideoStreamTextureProgram* program = videoStreamTextureProgram(); |
941 GLC(context(), context()->useProgram(program->program())); | 943 setUseProgram(program->program()); |
942 | 944 |
943 toGLMatrix(&glMatrix[0], quad->matrix); | 945 toGLMatrix(&glMatrix[0], quad->matrix); |
944 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().texMatrix Location(), 1, false, glMatrix)); | 946 GLC(context(), context()->uniformMatrix4fv(program->vertexShader().texMatrix Location(), 1, false, glMatrix)); |
945 | 947 |
946 GLC(context(), context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture _id)); | 948 GLC(context(), context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture _id)); |
947 | 949 |
948 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio n(), 0)); | 950 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio n(), 0)); |
949 | 951 |
950 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ; | 952 setShaderOpacity(quad->opacity(), program->fragmentShader().alphaLocation()) ; |
951 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh ader().matrixLocation()); | 953 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, program->vertexSh ader().matrixLocation()); |
(...skipping 18 matching lines...) Expand all Loading... | |
970 struct TexTransformTextureProgramBinding : TextureProgramBinding { | 972 struct TexTransformTextureProgramBinding : TextureProgramBinding { |
971 template<class Program> void set( | 973 template<class Program> void set( |
972 Program* program, WebKit::WebGraphicsContext3D* context) | 974 Program* program, WebKit::WebGraphicsContext3D* context) |
973 { | 975 { |
974 TextureProgramBinding::set(program, context); | 976 TextureProgramBinding::set(program, context); |
975 texTransformLocation = program->vertexShader().texTransformLocation(); | 977 texTransformLocation = program->vertexShader().texTransformLocation(); |
976 } | 978 } |
977 int texTransformLocation; | 979 int texTransformLocation; |
978 }; | 980 }; |
979 | 981 |
982 void GLRenderer::flushTextureQuadCache() | |
983 { | |
984 // Check to see if we have anything to draw | |
jamesr
2012/11/29 11:17:11
nit: end comments with a period as if they were a
whunt
2012/11/29 23:55:06
Done, but Why?? They're not complete sentences...
| |
985 if (m_drawCache.programID == 0) | |
986 return; | |
987 | |
988 // Set the correct blending mode | |
989 setBlendEnabled(m_drawCache.needsBlending); | |
990 | |
991 // Bind the program to the GL state | |
992 setUseProgram(m_drawCache.programID); | |
993 | |
994 // Assume the current active textures is 0 | |
995 //GLC(context(), context()->activeTexture(GL_TEXTURE0)); | |
jamesr
2012/11/29 11:17:11
I would prefer deleting this line to commenting it
| |
996 ResourceProvider::ScopedReadLockGL lockedQuad(m_resourceProvider, m_drawCach e.resourceID); | |
997 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, lockedQuad.textureId()) ); | |
998 | |
999 // set up premultiplied alpha | |
1000 if (!m_drawCache.usePremultipliedAlpha) { | |
1001 // As it turns out, the premultiplied alpha blending function (ONE, ONE_MI NUS_SRC_ALPHA) | |
1002 // will never cause the alpha channel to be set to anything less than 1. 0 if it is | |
1003 // initialized to that value! Therefore, premultipliedAlpha being false is the first | |
1004 // situation we can generally see an alpha channel less than 1.0 coming out of the | |
1005 // compositor. This is causing platform differences in some layout tests (see | |
1006 // https://bugs.webkit.org/show_bug.cgi?id=82412), so in this situation, use a separate | |
1007 // blend function for the alpha channel to avoid modifying it. Don't use colorMask for this | |
1008 // as it has performance implications on some platforms. | |
1009 GLC(context(), context()->blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_S RC_ALPHA, GL_ZERO, GL_ONE)); | |
1010 } | |
1011 | |
1012 // Set the shader opacity | |
1013 setShaderOpacity(m_drawCache.alpha, m_drawCache.alphaLocation); | |
1014 | |
1015 DCHECK(sizeof(float4) == 4 * sizeof(float)); | |
jamesr
2012/11/29 11:17:11
You can do this with COMPILE_ASSERT() from base/ba
| |
1016 DCHECK(sizeof(float16) == 16 * sizeof(float)); | |
1017 | |
1018 // Upload the tranforms for both points and uvs | |
1019 GLC(m_context, m_context->uniformMatrix4fv((int)m_drawCache.matrixLocation, (int)m_drawCache.matrixData.size(), false, (float*)&m_drawCache.matrixData.front ())); | |
1020 GLC(m_context, m_context->uniform4fv((int)m_drawCache.uvXformLocation, (int) m_drawCache.uvXformData.size(), (float*)&m_drawCache.uvXformData.front())); | |
1021 | |
1022 // Draw the quads! | |
1023 GLC(m_context, m_context->drawElements(GL_TRIANGLES, 6 * m_drawCache.matrixD ata.size(), GL_UNSIGNED_SHORT, 0)); | |
1024 | |
1025 // Clean up after ourselves (reset state set above) | |
1026 if (!m_drawCache.usePremultipliedAlpha) | |
1027 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | |
1028 | |
1029 // Clear the cache | |
1030 m_drawCache.programID = 0; | |
1031 m_drawCache.uvXformData.resize(0); | |
1032 m_drawCache.matrixData.resize(0); | |
1033 } | |
1034 | |
1035 void GLRenderer::enqueueTextureQuad(const DrawingFrame& frame, const TextureDraw Quad* quad) | |
1036 { | |
1037 // Choose the correcte texture program binding | |
1038 TexTransformTextureProgramBinding binding; | |
1039 if (quad->flipped) | |
1040 binding.set(textureProgramFlip(), context()); | |
1041 else | |
1042 binding.set(textureProgram(), context()); | |
1043 | |
1044 int resourceID = quad->resource_id; | |
1045 | |
1046 if (m_drawCache.programID != binding.programId || | |
jamesr
2012/11/29 11:17:11
I think this is a little more spaced out than we n
whunt
2012/11/29 23:55:06
More importantly, it wouldn't be block-editable fo
| |
1047 m_drawCache.resourceID != resourceID || | |
1048 m_drawCache.alpha != quad->opacity() || | |
1049 m_drawCache.usePremultipliedAlpha != quad->premultiplied_alpha || | |
1050 m_drawCache.needsBlending != quad->ShouldDrawWithBlending() || | |
1051 m_drawCache.matrixData.size() >= 8) | |
1052 { | |
1053 flushTextureQuadCache(); | |
1054 m_drawCache.programID = binding.programId; | |
1055 m_drawCache.resourceID = resourceID; | |
1056 m_drawCache.alpha = quad->opacity(); | |
1057 m_drawCache.usePremultipliedAlpha = quad->premultiplied_alpha; | |
1058 m_drawCache.needsBlending = quad->ShouldDrawWithBlending(); | |
1059 | |
1060 m_drawCache.alphaLocation = binding.alphaLocation; | |
1061 m_drawCache.uvXformLocation = binding.texTransformLocation; | |
1062 m_drawCache.matrixLocation = binding.matrixLocation; | |
1063 } | |
1064 | |
1065 // Generate the uv-transform | |
1066 const gfx::RectF& uvRect = quad->uv_rect; | |
1067 float4 uv = {uvRect.x(), uvRect.y(), uvRect.width(), uvRect.height()}; | |
1068 m_drawCache.uvXformData.push_back(uv); | |
1069 | |
1070 // Generate the transform matrix | |
1071 gfx::Transform quadRectMatrix; | |
1072 quadRectTransform(&quadRectMatrix, quad->quadTransform(), quad->rect); | |
1073 quadRectMatrix = frame.projectionMatrix * quadRectMatrix; | |
1074 | |
1075 float16 m; | |
1076 quadRectMatrix.matrix().asColMajorf(m.data); | |
1077 m_drawCache.matrixData.push_back(m); | |
1078 } | |
1079 | |
980 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad) | 1080 void GLRenderer::drawTextureQuad(const DrawingFrame& frame, const TextureDrawQua d* quad) |
981 { | 1081 { |
982 TexTransformTextureProgramBinding binding; | 1082 TexTransformTextureProgramBinding binding; |
983 if (quad->flipped) | 1083 if (quad->flipped) |
984 binding.set(textureProgramFlip(), context()); | 1084 binding.set(textureProgramFlip(), context()); |
985 else | 1085 else |
986 binding.set(textureProgram(), context()); | 1086 binding.set(textureProgram(), context()); |
987 GLC(context(), context()->useProgram(binding.programId)); | 1087 setUseProgram(binding.programId); |
988 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); | 1088 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); |
989 const gfx::RectF& uvRect = quad->uv_rect; | 1089 const gfx::RectF& uvRect = quad->uv_rect; |
990 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); | 1090 GLC(context(), context()->uniform4f(binding.texTransformLocation, uvRect.x() , uvRect.y(), uvRect.width(), uvRect.height())); |
991 | 1091 |
992 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad ->resource_id); | 1092 ResourceProvider::ScopedReadLockGL quadResourceLock(m_resourceProvider, quad ->resource_id); |
993 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur eId())); | 1093 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, quadResourceLock.textur eId())); |
994 | 1094 |
995 if (!quad->premultiplied_alpha) { | 1095 if (!quad->premultiplied_alpha) { |
996 // As it turns out, the premultiplied alpha blending function (ONE, ONE_ MINUS_SRC_ALPHA) | 1096 // As it turns out, the premultiplied alpha blending function (ONE, ONE_ MINUS_SRC_ALPHA) |
997 // will never cause the alpha channel to be set to anything less than 1. 0 if it is | 1097 // will never cause the alpha channel to be set to anything less than 1. 0 if it is |
(...skipping 11 matching lines...) Expand all Loading... | |
1009 | 1109 |
1010 if (!quad->premultiplied_alpha) | 1110 if (!quad->premultiplied_alpha) |
1011 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 1111 GLC(m_context, m_context->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
1012 } | 1112 } |
1013 | 1113 |
1014 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad) | 1114 void GLRenderer::drawIOSurfaceQuad(const DrawingFrame& frame, const IOSurfaceDra wQuad* quad) |
1015 { | 1115 { |
1016 TexTransformTextureProgramBinding binding; | 1116 TexTransformTextureProgramBinding binding; |
1017 binding.set(textureIOSurfaceProgram(), context()); | 1117 binding.set(textureIOSurfaceProgram(), context()); |
1018 | 1118 |
1019 GLC(context(), context()->useProgram(binding.programId)); | 1119 setUseProgram(binding.programId); |
1020 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); | 1120 GLC(context(), context()->uniform1i(binding.samplerLocation, 0)); |
1021 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) | 1121 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) |
1022 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)); | 1122 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)); |
1023 else | 1123 else |
1024 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->io_surface_size.width(), quad->io_surface_size.height())); | 1124 GLC(context(), context()->uniform4f(binding.texTransformLocation, 0, 0, quad->io_surface_size.width(), quad->io_surface_size.height())); |
1025 | 1125 |
1026 GLC(context(), context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, quad->io_sur face_texture_id)); | 1126 GLC(context(), context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, quad->io_sur face_texture_id)); |
1027 | 1127 |
1028 setShaderOpacity(quad->opacity(), binding.alphaLocation); | 1128 setShaderOpacity(quad->opacity(), binding.alphaLocation); |
1029 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, binding.matrixLoc ation); | 1129 drawQuadGeometry(frame, quad->quadTransform(), quad->rect, binding.matrixLoc ation); |
1030 | 1130 |
1031 GLC(context(), context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); | 1131 GLC(context(), context()->bindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); |
1032 } | 1132 } |
1033 | 1133 |
1034 void GLRenderer::finishDrawingFrame(DrawingFrame& frame) | 1134 void GLRenderer::finishDrawingFrame(DrawingFrame& frame) |
1035 { | 1135 { |
1036 m_currentFramebufferLock.reset(); | 1136 m_currentFramebufferLock.reset(); |
1037 m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect)); | 1137 m_swapBufferRect.Union(gfx::ToEnclosingRect(frame.rootDamageRect)); |
1038 | 1138 |
1039 GLC(m_context, m_context->disable(GL_BLEND)); | 1139 GLC(m_context, m_context->disable(GL_BLEND)); |
1140 m_blendShadow = false; | |
1141 } | |
1142 | |
1143 void GLRenderer::finishDrawingQuadList() | |
1144 { | |
1145 flushTextureQuadCache(); | |
1040 } | 1146 } |
1041 | 1147 |
1042 bool GLRenderer::flippedFramebuffer() const | 1148 bool GLRenderer::flippedFramebuffer() const |
1043 { | 1149 { |
1044 return true; | 1150 return true; |
1045 } | 1151 } |
1046 | 1152 |
1047 void GLRenderer::ensureScissorTestEnabled() | 1153 void GLRenderer::ensureScissorTestEnabled() |
1048 { | 1154 { |
1049 if (m_isScissorEnabled) | 1155 if (m_isScissorEnabled) |
1050 return; | 1156 return; |
1051 | 1157 |
1158 flushTextureQuadCache(); | |
1052 GLC(m_context, m_context->enable(GL_SCISSOR_TEST)); | 1159 GLC(m_context, m_context->enable(GL_SCISSOR_TEST)); |
1053 m_isScissorEnabled = true; | 1160 m_isScissorEnabled = true; |
1054 } | 1161 } |
1055 | 1162 |
1056 void GLRenderer::ensureScissorTestDisabled() | 1163 void GLRenderer::ensureScissorTestDisabled() |
1057 { | 1164 { |
1058 if (!m_isScissorEnabled) | 1165 if (!m_isScissorEnabled) |
1059 return; | 1166 return; |
1060 | 1167 |
1168 flushTextureQuadCache(); | |
1061 GLC(m_context, m_context->disable(GL_SCISSOR_TEST)); | 1169 GLC(m_context, m_context->disable(GL_SCISSOR_TEST)); |
1062 m_isScissorEnabled = false; | 1170 m_isScissorEnabled = false; |
1063 } | 1171 } |
1064 | 1172 |
1065 void GLRenderer::toGLMatrix(float* glMatrix, const gfx::Transform& transform) | 1173 void GLRenderer::toGLMatrix(float* glMatrix, const gfx::Transform& transform) |
1066 { | 1174 { |
1067 transform.matrix().asColMajorf(glMatrix); | 1175 transform.matrix().asColMajorf(glMatrix); |
1068 } | 1176 } |
1069 | 1177 |
1070 void GLRenderer::setShaderQuadF(const gfx::QuadF& quad, int quadLocation) | 1178 void GLRenderer::setShaderQuadF(const gfx::QuadF& quad, int quadLocation) |
(...skipping 12 matching lines...) Expand all Loading... | |
1083 point[7] = quad.p4().y(); | 1191 point[7] = quad.p4().y(); |
1084 GLC(m_context, m_context->uniform2fv(quadLocation, 4, point)); | 1192 GLC(m_context, m_context->uniform2fv(quadLocation, 4, point)); |
1085 } | 1193 } |
1086 | 1194 |
1087 void GLRenderer::setShaderOpacity(float opacity, int alphaLocation) | 1195 void GLRenderer::setShaderOpacity(float opacity, int alphaLocation) |
1088 { | 1196 { |
1089 if (alphaLocation != -1) | 1197 if (alphaLocation != -1) |
1090 GLC(m_context, m_context->uniform1f(alphaLocation, opacity)); | 1198 GLC(m_context, m_context->uniform1f(alphaLocation, opacity)); |
1091 } | 1199 } |
1092 | 1200 |
1201 void GLRenderer::setBlendEnabled(bool enabled) | |
1202 { | |
1203 if (enabled != m_blendShadow) | |
jamesr
2012/11/29 11:17:11
we generally prefer to early return so the indenta
| |
1204 { | |
1205 if (enabled) | |
1206 GLC(m_context, m_context->enable(GL_BLEND)); | |
1207 else | |
1208 GLC(m_context, m_context->disable(GL_BLEND)); | |
1209 m_blendShadow = enabled; | |
1210 } | |
1211 } | |
1212 | |
1213 void GLRenderer::setUseProgram(unsigned program) | |
1214 { | |
1215 if (program != m_programShadow) | |
jamesr
2012/11/29 11:17:11
same here
| |
1216 { | |
1217 GLC(m_context, m_context->useProgram(program)); | |
1218 m_programShadow = program; | |
1219 } | |
1220 } | |
1221 | |
1093 void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const gfx::Transfor m& drawTransform, const gfx::RectF& quadRect, int matrixLocation) | 1222 void GLRenderer::drawQuadGeometry(const DrawingFrame& frame, const gfx::Transfor m& drawTransform, const gfx::RectF& quadRect, int matrixLocation) |
1094 { | 1223 { |
1095 gfx::Transform quadRectMatrix; | 1224 gfx::Transform quadRectMatrix; |
1096 quadRectTransform(&quadRectMatrix, drawTransform, quadRect); | 1225 quadRectTransform(&quadRectMatrix, drawTransform, quadRect); |
1097 static float glMatrix[16]; | 1226 static float glMatrix[16]; |
1098 toGLMatrix(&glMatrix[0], frame.projectionMatrix * quadRectMatrix); | 1227 toGLMatrix(&glMatrix[0], frame.projectionMatrix * quadRectMatrix); |
1099 GLC(m_context, m_context->uniformMatrix4fv(matrixLocation, 1, false, &glMatr ix[0])); | 1228 GLC(m_context, m_context->uniformMatrix4fv(matrixLocation, 1, false, &glMatr ix[0])); |
1100 | 1229 |
1101 GLC(m_context, m_context->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0 )); | 1230 GLC(m_context, m_context->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0 )); |
1102 } | 1231 } |
1103 | 1232 |
1104 void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int texture Id, const gfx::Rect& rect, const gfx::Transform& drawMatrix) | 1233 void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int texture Id, const gfx::Rect& rect, const gfx::Transform& drawMatrix) |
1105 { | 1234 { |
1106 const RenderPassProgram* program = renderPassProgram(); | 1235 const RenderPassProgram* program = renderPassProgram(); |
1107 | 1236 |
1108 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, textureId)); | 1237 GLC(context(), context()->bindTexture(GL_TEXTURE_2D, textureId)); |
1109 | 1238 |
1110 GLC(context(), context()->useProgram(program->program())); | 1239 setUseProgram(program->program()); |
1111 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio n(), 0)); | 1240 GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocatio n(), 0)); |
1112 setShaderOpacity(1, program->fragmentShader().alphaLocation()); | 1241 setShaderOpacity(1, program->fragmentShader().alphaLocation()); |
1113 drawQuadGeometry(frame, drawMatrix, rect, program->vertexShader().matrixLoca tion()); | 1242 drawQuadGeometry(frame, drawMatrix, rect, program->vertexShader().matrixLoca tion()); |
1114 } | 1243 } |
1115 | 1244 |
1116 void GLRenderer::finish() | 1245 void GLRenderer::finish() |
1117 { | 1246 { |
1118 TRACE_EVENT0("cc", "GLRenderer::finish"); | 1247 TRACE_EVENT0("cc", "GLRenderer::finish"); |
1119 m_context->finish(); | 1248 m_context->finish(); |
1120 } | 1249 } |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 void GLRenderer::setScissorTestRect(const gfx::Rect& scissorRect) | 1480 void GLRenderer::setScissorTestRect(const gfx::Rect& scissorRect) |
1352 { | 1481 { |
1353 ensureScissorTestEnabled(); | 1482 ensureScissorTestEnabled(); |
1354 | 1483 |
1355 // Don't unnecessarily ask the context to change the scissor, because it | 1484 // Don't unnecessarily ask the context to change the scissor, because it |
1356 // may cause undesired GPU pipeline flushes. | 1485 // may cause undesired GPU pipeline flushes. |
1357 if (scissorRect == m_scissorRect) | 1486 if (scissorRect == m_scissorRect) |
1358 return; | 1487 return; |
1359 | 1488 |
1360 m_scissorRect = scissorRect; | 1489 m_scissorRect = scissorRect; |
1490 flushTextureQuadCache(); | |
1361 GLC(m_context, m_context->scissor(scissorRect.x(), scissorRect.y(), scissorR ect.width(), scissorRect.height())); | 1491 GLC(m_context, m_context->scissor(scissorRect.x(), scissorRect.y(), scissorR ect.width(), scissorRect.height())); |
1362 } | 1492 } |
1363 | 1493 |
1364 void GLRenderer::setDrawViewportSize(const gfx::Size& viewportSize) | 1494 void GLRenderer::setDrawViewportSize(const gfx::Size& viewportSize) |
1365 { | 1495 { |
1366 GLC(m_context, m_context->viewport(0, 0, viewportSize.width(), viewportSize. height())); | 1496 GLC(m_context, m_context->viewport(0, 0, viewportSize.width(), viewportSize. height())); |
1367 } | 1497 } |
1368 | 1498 |
1369 bool GLRenderer::makeContextCurrent() | 1499 bool GLRenderer::makeContextCurrent() |
1370 { | 1500 { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1520 return m_tileProgramSwizzleAA.get(); | 1650 return m_tileProgramSwizzleAA.get(); |
1521 } | 1651 } |
1522 | 1652 |
1523 const GLRenderer::TextureProgram* GLRenderer::textureProgram() | 1653 const GLRenderer::TextureProgram* GLRenderer::textureProgram() |
1524 { | 1654 { |
1525 if (!m_textureProgram) | 1655 if (!m_textureProgram) |
1526 m_textureProgram = make_scoped_ptr(new TextureProgram(m_context)); | 1656 m_textureProgram = make_scoped_ptr(new TextureProgram(m_context)); |
1527 if (!m_textureProgram->initialized()) { | 1657 if (!m_textureProgram->initialized()) { |
1528 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 1658 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
1529 m_textureProgram->initialize(m_context, m_isUsingBindUniform); | 1659 m_textureProgram->initialize(m_context, m_isUsingBindUniform); |
1660 GLC(context(), context()->uniform1i(m_textureProgram.get()->fragmentShad er().samplerLocation(), 0)); | |
1530 } | 1661 } |
1531 return m_textureProgram.get(); | 1662 return m_textureProgram.get(); |
1532 } | 1663 } |
1533 | 1664 |
1534 const GLRenderer::TextureProgramFlip* GLRenderer::textureProgramFlip() | 1665 const GLRenderer::TextureProgramFlip* GLRenderer::textureProgramFlip() |
1535 { | 1666 { |
1536 if (!m_textureProgramFlip) | 1667 if (!m_textureProgramFlip) |
1537 m_textureProgramFlip = make_scoped_ptr(new TextureProgramFlip(m_context) ); | 1668 m_textureProgramFlip = make_scoped_ptr(new TextureProgramFlip(m_context) ); |
1538 if (!m_textureProgramFlip->initialized()) { | 1669 if (!m_textureProgramFlip->initialized()) { |
1539 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); | 1670 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); |
1540 m_textureProgramFlip->initialize(m_context, m_isUsingBindUniform); | 1671 m_textureProgramFlip->initialize(m_context, m_isUsingBindUniform); |
1672 GLC(context(), context()->uniform1i(m_textureProgramFlip.get()->fragment Shader().samplerLocation(), 0)); | |
1541 } | 1673 } |
1542 return m_textureProgramFlip.get(); | 1674 return m_textureProgramFlip.get(); |
1543 } | 1675 } |
1544 | 1676 |
1545 const GLRenderer::TextureIOSurfaceProgram* GLRenderer::textureIOSurfaceProgram() | 1677 const GLRenderer::TextureIOSurfaceProgram* GLRenderer::textureIOSurfaceProgram() |
1546 { | 1678 { |
1547 if (!m_textureIOSurfaceProgram) | 1679 if (!m_textureIOSurfaceProgram) |
1548 m_textureIOSurfaceProgram = make_scoped_ptr(new TextureIOSurfaceProgram( m_context)); | 1680 m_textureIOSurfaceProgram = make_scoped_ptr(new TextureIOSurfaceProgram( m_context)); |
1549 if (!m_textureIOSurfaceProgram->initialized()) { | 1681 if (!m_textureIOSurfaceProgram->initialized()) { |
1550 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); | 1682 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1625 | 1757 |
1626 releaseRenderPassTextures(); | 1758 releaseRenderPassTextures(); |
1627 } | 1759 } |
1628 | 1760 |
1629 bool GLRenderer::isContextLost() | 1761 bool GLRenderer::isContextLost() |
1630 { | 1762 { |
1631 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); | 1763 return (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR); |
1632 } | 1764 } |
1633 | 1765 |
1634 } // namespace cc | 1766 } // namespace cc |
OLD | NEW |