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

Unified Diff: cc/gl_renderer.cc

Issue 11420079: Allow using a larger-than-necessary texture as cached render pass backing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: seems to work 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 side-by-side diff with in-line comments
Download patch
Index: cc/gl_renderer.cc
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index a40dd3a245b80e384bea0d7cce273d2d441ff6ba..a3ff91228af71050b7e5d997343a5e55ec1950b3 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -494,7 +494,7 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
// Copy the readback pixels from device to the background texture for the surface.
gfx::Transform deviceToFramebufferTransform;
deviceToFramebufferTransform.Translate(quad->rect.width() / 2.0, quad->rect.height() / 2.0);
- deviceToFramebufferTransform.Scale3d(quad->rect.width(), quad->rect.height(), 1);
+ deviceToFramebufferTransform.Scale(quad->rect.width(), quad->rect.height());
deviceToFramebufferTransform.PreconcatTransform(contentsDeviceTransformInverse);
copyTextureToFramebuffer(frame, filteredDeviceBackgroundTextureId, deviceRect, deviceToFramebufferTransform);
}
@@ -583,6 +583,9 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
int shaderMaskTexCoordOffsetLocation = -1;
int shaderMatrixLocation = -1;
int shaderAlphaLocation = -1;
+ int shaderTexTransformLocation = -1;
+ int shaderTexScaleLocation = -1;
+
if (useAA && maskTextureId) {
const RenderPassMaskProgramAA* program = renderPassMaskProgramAA();
setUseProgram(program->program());
@@ -595,6 +598,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
shaderMaskTexCoordOffsetLocation = program->fragmentShader().maskTexCoordOffsetLocation();
shaderMatrixLocation = program->vertexShader().matrixLocation();
shaderAlphaLocation = program->fragmentShader().alphaLocation();
+ shaderTexScaleLocation = program->vertexShader().texScaleLocation();
} else if (!useAA && maskTextureId) {
const RenderPassMaskProgram* program = renderPassMaskProgram();
setUseProgram(program->program());
@@ -605,6 +609,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
shaderMaskTexCoordOffsetLocation = program->fragmentShader().maskTexCoordOffsetLocation();
shaderMatrixLocation = program->vertexShader().matrixLocation();
shaderAlphaLocation = program->fragmentShader().alphaLocation();
+ shaderTexTransformLocation = program->vertexShader().texTransformLocation();
} else if (useAA && !maskTextureId) {
const RenderPassProgramAA* program = renderPassProgramAA();
setUseProgram(program->program());
@@ -614,6 +619,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
shaderEdgeLocation = program->fragmentShader().edgeLocation();
shaderMatrixLocation = program->vertexShader().matrixLocation();
shaderAlphaLocation = program->fragmentShader().alphaLocation();
+ shaderTexScaleLocation = program->vertexShader().texScaleLocation();
} else {
const RenderPassProgram* program = renderPassProgram();
setUseProgram(program->program());
@@ -621,6 +627,21 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
shaderMatrixLocation = program->vertexShader().matrixLocation();
shaderAlphaLocation = program->fragmentShader().alphaLocation();
+ shaderTexTransformLocation = program->vertexShader().texTransformLocation();
+ }
+
+ float tex_scale_x = quad->rect.width() / static_cast<float>(contentsTexture->size().width());
+ float tex_scale_y = quad->rect.height() / static_cast<float>(contentsTexture->size().height());
enne (OOO) 2012/12/12 23:41:54 Can you assert here that scale_foo is <= 1?
jamesr 2012/12/13 01:15:06 Sure
+
+ if (shaderTexTransformLocation != -1) {
+ GLC(context(), context()->uniform4f(shaderTexTransformLocation,
+ 0.0f, 0.0f,
+ tex_scale_x, tex_scale_y));
+ } else if (shaderTexScaleLocation != -1) {
+ GLC(context(), context()->uniform2f(shaderTexScaleLocation,
+ tex_scale_x, tex_scale_y));
+ } else {
+ NOTREACHED();
}
if (shaderMaskSamplerLocation != -1) {
@@ -628,8 +649,10 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
DCHECK(shaderMaskTexCoordOffsetLocation != 1);
GLC(context(), context()->activeTexture(GL_TEXTURE1));
GLC(context(), context()->uniform1i(shaderMaskSamplerLocation, 1));
- GLC(context(), context()->uniform2f(shaderMaskTexCoordScaleLocation, quad->mask_tex_coord_scale_x, quad->mask_tex_coord_scale_y));
- GLC(context(), context()->uniform2f(shaderMaskTexCoordOffsetLocation, quad->mask_tex_coord_offset_x, quad->mask_tex_coord_offset_y));
+ GLC(context(), context()->uniform2f(shaderMaskTexCoordOffsetLocation,
+ quad->mask_uv_rect.x(), quad->mask_uv_rect.y()));
+ GLC(context(), context()->uniform2f(shaderMaskTexCoordScaleLocation,
+ quad->mask_uv_rect.width() / tex_scale_x, quad->mask_uv_rect.height() / tex_scale_y));
m_resourceProvider->bindForSampling(quad->mask_resource_id, GL_TEXTURE_2D, GL_LINEAR);
GLC(context(), context()->activeTexture(GL_TEXTURE0));
}
@@ -641,6 +664,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
GLC(context(), context()->uniform3fv(shaderEdgeLocation, 8, edge));
}
+
// Map device space quad to surface space. contentsDeviceTransform has no 3d component since it was generated with to2dTransform() so we don't need to project.
gfx::QuadF surfaceQuad = MathUtil::mapQuad(contentsDeviceTransformInverse, deviceLayerEdges.ToQuadF(), clipped);
DCHECK(!clipped);
@@ -1228,6 +1252,8 @@ void GLRenderer::copyTextureToFramebuffer(const DrawingFrame& frame, int texture
setUseProgram(program->program());
GLC(context(), context()->uniform1i(program->fragmentShader().samplerLocation(), 0));
+ GLC(context(), context()->uniform4f(program->vertexShader().texTransformLocation(),
enne (OOO) 2012/12/12 23:41:54 It's kind of scary that this wasn't set before.
jamesr 2012/12/13 01:15:06 Not as scary as it seems - I'm adding this vertex
+ 0.0f, 0.0f, 1.0f, 1.0f));
setShaderOpacity(1, program->fragmentShader().alphaLocation());
drawQuadGeometry(frame, drawMatrix, rect, program->vertexShader().matrixLocation());
}
« no previous file with comments | « cc/gl_renderer.h ('k') | cc/gl_renderer_pixeltest.cc » ('j') | cc/gl_renderer_pixeltest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698