Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: cc/gl_renderer.cc

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

Powered by Google App Engine
This is Rietveld 408576698