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

Side by Side Diff: cc/tiles/picture_layer_tiling.cc

Issue 2555363004: [6/6] git cl format (Closed)
Patch Set: Created 4 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
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/tiles/tile.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/tiles/picture_layer_tiling.h" 5 #include "cc/tiles/picture_layer_tiling.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 return tiling_data_.max_texture_size() == 374 return tiling_data_.max_texture_size() ==
375 twin->tiling_data_.max_texture_size(); 375 twin->tiling_data_.max_texture_size();
376 } 376 }
377 377
378 PictureLayerTiling::CoverageIterator::CoverageIterator() = default; 378 PictureLayerTiling::CoverageIterator::CoverageIterator() = default;
379 379
380 PictureLayerTiling::CoverageIterator::CoverageIterator( 380 PictureLayerTiling::CoverageIterator::CoverageIterator(
381 const PictureLayerTiling* tiling, 381 const PictureLayerTiling* tiling,
382 float coverage_scale, 382 float coverage_scale,
383 const gfx::Rect& coverage_rect) 383 const gfx::Rect& coverage_rect)
384 : tiling_(tiling) 384 : tiling_(tiling),
385 , coverage_rect_(coverage_rect) 385 coverage_rect_(coverage_rect),
386 , coverage_to_content_(ScaleTranslate2d::PreScale(tiling->raster_transform() , 1.f / coverage_scale)) { 386 coverage_to_content_(
387 ScaleTranslate2d::PreScale(tiling->raster_transform(),
388 1.f / coverage_scale)) {
387 DCHECK(tiling_); 389 DCHECK(tiling_);
388 // In order to avoid artifacts in geometry_rect scaling and clamping to ints, 390 // In order to avoid artifacts in geometry_rect scaling and clamping to ints,
389 // the |coverage_scale| should always be at least as big as the tiling's 391 // the |coverage_scale| should always be at least as big as the tiling's
390 // raster scales. 392 // raster scales.
391 DCHECK_GE(coverage_scale, tiling_->raster_transform_.scale()); 393 DCHECK_GE(coverage_scale, tiling_->raster_transform_.scale());
392 394
393 // Clamp |coverage_rect| to the bounds of this tiling's raster source. 395 // Clamp |coverage_rect| to the bounds of this tiling's raster source.
394 coverage_rect_max_bounds_ = 396 coverage_rect_max_bounds_ =
395 gfx::ScaleToCeiledSize(tiling->raster_source_->GetSize(), coverage_scale); 397 gfx::ScaleToCeiledSize(tiling->raster_source_->GetSize(), coverage_scale);
396 coverage_rect_.Intersect(gfx::Rect(coverage_rect_max_bounds_)); 398 coverage_rect_.Intersect(gfx::Rect(coverage_rect_max_bounds_));
397 if (coverage_rect_.IsEmpty()) 399 if (coverage_rect_.IsEmpty())
398 return; 400 return;
399 401
400 // Find the indices of the texel samples that enclose the rect we want to 402 // Find the indices of the texel samples that enclose the rect we want to
401 // cover. 403 // cover.
402 // Because we don't know the target transform at this point, we have to be 404 // Because we don't know the target transform at this point, we have to be
403 // pessimistic, i.e. assume every point (a pair of real number, not necessary 405 // pessimistic, i.e. assume every point (a pair of real number, not necessary
404 // snapped to a pixel sample) inside of the content rect may be sampled. 406 // snapped to a pixel sample) inside of the content rect may be sampled.
405 // This code maps the boundary points into contents space, then find out the 407 // This code maps the boundary points into contents space, then find out the
406 // enclosing texture samples. For example, assume we have: 408 // enclosing texture samples. For example, assume we have:
407 // coverage_scale : content_scale = 1.23 : 1 409 // coverage_scale : content_scale = 1.23 : 1
408 // coverage_rect = (l:123, t:234, r:345, b:456) 410 // coverage_rect = (l:123, t:234, r:345, b:456)
409 // Then it follows that: 411 // Then it follows that:
410 // content_rect = (l:100.00, t:190.24, r:280.49, b:370.73) 412 // content_rect = (l:100.00, t:190.24, r:280.49, b:370.73)
411 // Without MSAA, the sample point of a texel is at the center of that texel, 413 // Without MSAA, the sample point of a texel is at the center of that texel,
412 // thus the sample points we need to cover content_rect are: 414 // thus the sample points we need to cover content_rect are:
413 // wanted_texels(sample coordinates) = (l:99.5, t:189.5, r:280.5, b:371.5) 415 // wanted_texels(sample coordinates) = (l:99.5, t:189.5, r:280.5, b:371.5)
414 // Or in integer index: 416 // Or in integer index:
415 // wanted_texels(integer index) = (l:99, t:189, r:280, b:371) 417 // wanted_texels(integer index) = (l:99, t:189, r:280, b:371)
416 gfx::RectF content_rect = coverage_to_content_.TransformRect(gfx::RectF(covera ge_rect_)); 418 gfx::RectF content_rect =
419 coverage_to_content_.TransformRect(gfx::RectF(coverage_rect_));
417 content_rect.Offset(-0.5f, -0.5f); 420 content_rect.Offset(-0.5f, -0.5f);
418 gfx::Rect wanted_texels = gfx::ToEnclosingRect(content_rect); 421 gfx::Rect wanted_texels = gfx::ToEnclosingRect(content_rect);
419 422
420 const TilingData& data = tiling_->tiling_data_; 423 const TilingData& data = tiling_->tiling_data_;
421 left_ = data.LastBorderTileXIndexFromSrcCoord(wanted_texels.x()); 424 left_ = data.LastBorderTileXIndexFromSrcCoord(wanted_texels.x());
422 top_ = data.LastBorderTileYIndexFromSrcCoord(wanted_texels.y()); 425 top_ = data.LastBorderTileYIndexFromSrcCoord(wanted_texels.y());
423 right_ = std::max( 426 right_ = std::max(
424 left_, data.FirstBorderTileXIndexFromSrcCoord(wanted_texels.right())); 427 left_, data.FirstBorderTileXIndexFromSrcCoord(wanted_texels.right()));
425 bottom_ = std::max( 428 bottom_ = std::max(
426 top_, data.FirstBorderTileYIndexFromSrcCoord(wanted_texels.bottom())); 429 top_, data.FirstBorderTileYIndexFromSrcCoord(wanted_texels.bottom()));
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 size_t amount = 0; 939 size_t amount = 0;
937 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 940 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
938 const Tile* tile = it->second.get(); 941 const Tile* tile = it->second.get();
939 amount += tile->GPUMemoryUsageInBytes(); 942 amount += tile->GPUMemoryUsageInBytes();
940 } 943 }
941 return amount; 944 return amount;
942 } 945 }
943 946
944 gfx::Rect PictureLayerTiling::EnclosingContentsRectFromLayerRect( 947 gfx::Rect PictureLayerTiling::EnclosingContentsRectFromLayerRect(
945 const gfx::Rect& layer_rect) const { 948 const gfx::Rect& layer_rect) const {
946 return ToEnclosingRect(raster_transform_.TransformRect(gfx::RectF(layer_rect)) ); 949 return ToEnclosingRect(
950 raster_transform_.TransformRect(gfx::RectF(layer_rect)));
947 } 951 }
948 952
949 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect( 953 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect(
950 const gfx::Rect& contents_rect) const { 954 const gfx::Rect& contents_rect) const {
951 return ToEnclosingRect( 955 return ToEnclosingRect(
952 raster_transform_.TransformRectReverse(gfx::RectF(contents_rect))); 956 raster_transform_.TransformRectReverse(gfx::RectF(contents_rect)));
953 } 957 }
954 958
955 } // namespace cc 959 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/tiles/tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698