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

Unified Diff: cc/picture_layer_tiling.cc

Issue 12220133: cc: Stretch textures by .5 texels to prevent out of bounds sampling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix cc_unittests Created 7 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
Index: cc/picture_layer_tiling.cc
diff --git a/cc/picture_layer_tiling.cc b/cc/picture_layer_tiling.cc
index ae3afc39d0451f79f96449138fba168f8f90ae2a..f47f453cf2b53db3bd3e087e7a08f093277f805b 100644
--- a/cc/picture_layer_tiling.cc
+++ b/cc/picture_layer_tiling.cc
@@ -133,7 +133,8 @@ void PictureLayerTiling::Invalidate(const Region& layer_invalidation) {
gfx::Rect rect =
gfx::ToEnclosingRect(ScaleRect(layer_invalidation, contents_scale_));
- for (PictureLayerTiling::Iterator tile_iter(this, contents_scale_, rect);
+ for (PictureLayerTiling::Iterator tile_iter(this, contents_scale_, rect,
+ PictureLayerTiling::LayerDeviceAlignmentUnknown);
tile_iter;
++tile_iter) {
TileMapKey key(tile_iter.tile_i_, tile_iter.tile_j_);
@@ -180,7 +181,8 @@ PictureLayerTiling::Iterator::Iterator()
PictureLayerTiling::Iterator::Iterator(const PictureLayerTiling* tiling,
float dest_scale,
- gfx::Rect dest_rect)
+ gfx::Rect dest_rect,
+ LayerDeviceAlignment layerDeviceAlignment)
: tiling_(tiling),
dest_rect_(dest_rect),
current_tile_(NULL),
@@ -213,6 +215,21 @@ PictureLayerTiling::Iterator::Iterator(const PictureLayerTiling* tiling,
dest_to_content_scale_y_ = content_size_floor.height() /
static_cast<float>(dest_content_size.height());
+ // It's possible that when drawing a quad with texel:pixel ratio < 1
+ // GL_LINEAR will cause us to blend in invalid texels.
+ // We stretch the content a little more to prevent sampling past the
+ // middle of the last texel.
+ if (layerDeviceAlignment == LayerAlignedToDevice){
brianderson 2013/02/13 00:10:19 This is where the scale is taken into account. Al
+ if (dest_to_content_scale_x_ < 1.0)
+ dest_to_content_scale_x_ -= 0.5f / dest_content_size.width();
+ if (dest_to_content_scale_y_ < 1.0)
+ dest_to_content_scale_y_ -= 0.5f / dest_content_size.height();
+ }
+ else if (layerDeviceAlignment == LayerNotAlignedToDevice) {
+ dest_to_content_scale_x_ -= 0.5f / dest_content_size.width();
+ dest_to_content_scale_y_ -= 0.5f / dest_content_size.height();
+ }
+
gfx::Rect content_rect =
gfx::ToEnclosingRect(gfx::ScaleRect(dest_rect_,
dest_to_content_scale_x_,

Powered by Google App Engine
This is Rietveld 408576698