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

Unified Diff: cc/trees/layer_tree_host_common.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common.cc
diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc
index f21ed3fb153db4bf4c06d3e7a787c719afff1091..70c5037221d1979579ac149f2fe0190b205834a9 100644
--- a/cc/trees/layer_tree_host_common.cc
+++ b/cc/trees/layer_tree_host_common.cc
@@ -21,6 +21,7 @@
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
#include "ui/gfx/transform.h"
+#include "ui/gfx/transform_util.h"
namespace cc {
@@ -1202,30 +1203,12 @@ struct PreCalculateMetaInformationRecursiveData {
}
};
-static bool ValidateRenderSurface(LayerImpl* layer) {
- // There are a few cases in which it is incorrect to not have a
- // render_surface.
- if (layer->render_surface())
- return true;
-
- return layer->filters().IsEmpty() && layer->background_filters().IsEmpty() &&
- !layer->mask_layer() && !layer->replica_layer() &&
- !IsRootLayer(layer) && !layer->is_root_for_isolated_group() &&
- !layer->HasCopyRequest();
-}
-
-static bool ValidateRenderSurface(Layer* layer) {
- return true;
-}
-
// Recursively walks the layer tree to compute any information that is needed
// before doing the main recursion.
template <typename LayerType>
static void PreCalculateMetaInformation(
LayerType* layer,
PreCalculateMetaInformationRecursiveData* recursive_data) {
- DCHECK(ValidateRenderSurface(layer));
-
layer->draw_properties().sorted_for_recursion = false;
layer->draw_properties().has_child_with_a_scroll_parent = false;
@@ -1271,11 +1254,6 @@ static void PreCalculateMetaInformation(
recursive_data->layer_or_descendant_has_input_handler;
}
-static void RoundTranslationComponents(gfx::Transform* transform) {
- transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3)));
- transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3)));
-}
-
template <typename LayerType>
struct SubtreeGlobals {
LayerSorter* layer_sorter;
@@ -1701,7 +1679,7 @@ static void CalculateDrawPropertiesInternal(
// blurriness. To avoid side-effects, do this only if the transform is
// simple.
gfx::Vector2dF previous_translation = combined_transform.To2dTranslation();
- RoundTranslationComponents(&combined_transform);
+ combined_transform.RoundTranslationComponents();
gfx::Vector2dF current_translation = combined_transform.To2dTranslation();
// This rounding changes the scroll delta, and so must be included
@@ -2491,6 +2469,12 @@ static bool ApproximatelyEqual(const gfx::Rect& r1, const gfx::Rect& r2) {
std::abs(r1.height() - r2.height()) <= tolerance;
}
+static bool ApproximatelyEqual(const gfx::Transform& a,
+ const gfx::Transform& b) {
+ static const float tolerance = 0.01f;
+ return gfx::MatrixDistance(a, b) < tolerance;
+}
+
void LayerTreeHostCommon::CalculateDrawProperties(
CalcDrawPropsMainInputs* inputs) {
UpdateRenderSurfaces(inputs->root_layer,
@@ -2520,8 +2504,8 @@ void LayerTreeHostCommon::CalculateDrawProperties(
DCHECK(inputs->root_layer->render_surface());
if (inputs->verify_property_trees) {
- // TODO(ajuma): Can we efficiently cache some of this rather than
- // starting from scratch every frame?
+ // The translation from layer to property trees is an intermediate state. We
+ // will eventually get these data passed directly to the compositor.
TransformTree transform_tree;
ClipTree clip_tree;
ComputeVisibleRectsUsingPropertyTrees(
@@ -2530,23 +2514,24 @@ void LayerTreeHostCommon::CalculateDrawProperties(
gfx::Rect(inputs->device_viewport_size), inputs->device_transform,
&transform_tree, &clip_tree);
- bool failed = false;
LayerIterator<Layer> it, end;
for (it = LayerIterator<Layer>::Begin(inputs->render_surface_layer_list),
end = LayerIterator<Layer>::End(inputs->render_surface_layer_list);
it != end; ++it) {
Layer* current_layer = *it;
- if (it.represents_itself()) {
- if (!failed && current_layer->DrawsContent() &&
- !ApproximatelyEqual(
- current_layer->visible_content_rect(),
- current_layer->visible_rect_from_property_trees())) {
- failed = true;
- }
- }
+ if (!it.represents_itself() || !current_layer->DrawsContent())
+ continue;
+
+ const bool visible_rects_match =
+ ApproximatelyEqual(current_layer->visible_content_rect(),
+ current_layer->visible_rect_from_property_trees());
+ CHECK(visible_rects_match);
+
+ const bool draw_transforms_match = ApproximatelyEqual(
+ current_layer->draw_transform(),
+ current_layer->draw_transform_from_property_trees(transform_tree));
+ CHECK(draw_transforms_match);
}
-
- CHECK(!failed);
}
}
« no previous file with comments | « cc/trees/layer_tree_host.cc ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698