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

Unified Diff: cc/output/gl_renderer.cc

Issue 909353003: cc: Translate filter when texture is larger than quad rect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gl -> sw Created 5 years, 10 months 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
« no previous file with comments | « no previous file | cc/test/data/enlarged_texture_on_threshold.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer.cc
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 15b2b4094446342de71d13be68421a0b93a3b340..a394a1adfe37f093ae0439057a14b1bdf5f42410 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -625,7 +625,7 @@ void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
static skia::RefPtr<SkImage> ApplyImageFilter(
scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
ResourceProvider* resource_provider,
- const gfx::Point& origin,
+ const gfx::Rect& rect,
const gfx::Vector2dF& scale,
SkImageFilter* filter,
ScopedResource* source_texture_resource) {
@@ -694,7 +694,12 @@ static skia::RefPtr<SkImage> ApplyImageFilter(
paint.setImageFilter(filter);
canvas->clear(SK_ColorTRANSPARENT);
- canvas->translate(SkIntToScalar(-origin.x()), SkIntToScalar(-origin.y()));
+ // The origin of the filter is top-left and the origin of the source is
+ // bottom-left, but the orientation is the same, so we must translate the
+ // filter so that it renders at the bottom of the texture to avoid
+ // misregistration.
+ int y_translate = source.height() - rect.height() - rect.origin().y();
+ canvas->translate(-rect.origin().x(), y_translate);
canvas->scale(scale.x(), scale.y());
canvas->drawSprite(source, 0, 0, &paint);
@@ -859,13 +864,9 @@ skia::RefPtr<SkImage> GLRenderer::ApplyBackgroundFilters(
skia::RefPtr<SkImageFilter> filter = RenderSurfaceFilters::BuildImageFilter(
quad->background_filters, background_texture->size());
- skia::RefPtr<SkImage> background_with_filters =
- ApplyImageFilter(ScopedUseGrContext::Create(this, frame),
- resource_provider_,
- quad->rect.origin(),
- quad->filters_scale,
- filter.get(),
- background_texture);
+ skia::RefPtr<SkImage> background_with_filters = ApplyImageFilter(
+ ScopedUseGrContext::Create(this, frame), resource_provider_, quad->rect,
+ quad->filters_scale, filter.get(), background_texture);
return background_with_filters;
}
@@ -971,12 +972,9 @@ void GLRenderer::DrawRenderPassQuad(DrawingFrame* frame,
// in the compositor.
use_color_matrix = true;
} else {
- filter_image = ApplyImageFilter(ScopedUseGrContext::Create(this, frame),
- resource_provider_,
- quad->rect.origin(),
- quad->filters_scale,
- filter.get(),
- contents_texture);
+ filter_image = ApplyImageFilter(
+ ScopedUseGrContext::Create(this, frame), resource_provider_,
+ quad->rect, quad->filters_scale, filter.get(), contents_texture);
}
}
}
« no previous file with comments | « no previous file | cc/test/data/enlarged_texture_on_threshold.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698