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

Unified Diff: cc/base/tiling_data.cc

Issue 2445363002: cc: Add functions for getting absolute tile indices.
Patch Set: Created 4 years, 2 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 | « cc/base/tiling_data.h ('k') | cc/base/tiling_data_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/tiling_data.cc
diff --git a/cc/base/tiling_data.cc b/cc/base/tiling_data.cc
index 98397e55ccfbb918b117e8c260ce088da6eabb9e..f8aa8351109b8498d0678619f045bbc02d565a41 100644
--- a/cc/base/tiling_data.cc
+++ b/cc/base/tiling_data.cc
@@ -91,6 +91,36 @@ int TilingData::TileYIndexFromSrcCoord(int src_position) const {
return std::min(std::max(y, 0), num_tiles_y_ - 1);
}
+int TilingData::TileAbsoluteXIndexFromSrcCoord(int src_position) const {
+ int inner_tile_width = max_texture_size_.width() - 2 * border_texels_;
+ if (inner_tile_width <= 0)
+ return 0;
+
+ int max_width = inner_tile_width * num_tiles_x_ + 2 * border_texels_;
+ if (src_position >= 0 && src_position < max_width)
+ return TileXIndexFromSrcCoord(src_position);
+
+ if (src_position >= max_width)
+ return num_tiles_x_ + (src_position - max_width) / inner_tile_width;
+
+ return (src_position + 1) / inner_tile_width - 1;
+}
+
+int TilingData::TileAbsoluteYIndexFromSrcCoord(int src_position) const {
+ int inner_tile_height = max_texture_size_.height() - 2 * border_texels_;
+ if (inner_tile_height <= 0)
+ return 0;
+
+ int max_height = inner_tile_height * num_tiles_y_ + 2 * border_texels_;
+ if (src_position >= 0 && src_position < max_height)
+ return TileYIndexFromSrcCoord(src_position);
+
+ if (src_position >= max_height)
+ return num_tiles_y_ + (src_position - max_height) / inner_tile_height;
+
+ return (src_position + 1) / inner_tile_height - 1;
+}
+
int TilingData::FirstBorderTileXIndexFromSrcCoord(int src_position) const {
if (num_tiles_x_ <= 1)
return 0;
« no previous file with comments | « cc/base/tiling_data.h ('k') | cc/base/tiling_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698