summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj <danakj@chromium.org>2015-02-11 13:07:47 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-11 21:08:17 +0000
commita1b92e49c1a4e9a517ff806278e2d4d8e13b7b0b (patch)
tree5e9a495d647ab78d37be4b4da6723d6b9b2fea4a /cc
parentc855c8079492d78efdabf1e93586acf4dda8726f (diff)
downloadchromium_src-a1b92e49c1a4e9a517ff806278e2d4d8e13b7b0b.zip
chromium_src-a1b92e49c1a4e9a517ff806278e2d4d8e13b7b0b.tar.gz
chromium_src-a1b92e49c1a4e9a517ff806278e2d4d8e13b7b0b.tar.bz2
cc: Stop passing OcclusionTracker to RenderSurfaceImpl.
This moves the code to grab the Occlusion off the tracker out to LayerTreeHostImpl. But the Occlusion depends on which draw transform to use, which depends on it being a replica or not. Since the decision to AppendQuads for a replica or not happens in LayerTreeHostImpl, we can branch there to decide which draw transform, occlusion, mask, and debug borders to use so that the logic is not split between two sites. Now |for_replica| is not passed to RenderSurfaceImpl::AppendQuads either. This removes one need to use an OcclusionTracker when walking layers to draw. R=enne, vmpstr BUG=446751 Review URL: https://codereview.chromium.org/914813003 Cr-Commit-Position: refs/heads/master@{#315834}
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/render_surface_impl.cc84
-rw-r--r--cc/layers/render_surface_impl.h16
-rw-r--r--cc/layers/render_surface_unittest.cc10
-rw-r--r--cc/test/layer_test_common.cc10
-rw-r--r--cc/test/layer_test_common.h2
-rw-r--r--cc/trees/layer_tree_host_impl.cc45
6 files changed, 86 insertions, 81 deletions
diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc
index 8f52316..2ca1241 100644
--- a/cc/layers/render_surface_impl.cc
+++ b/cc/layers/render_surface_impl.cc
@@ -18,7 +18,7 @@
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/shared_quad_state.h"
#include "cc/trees/damage_tracker.h"
-#include "cc/trees/occlusion_tracker.h"
+#include "cc/trees/occlusion.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/transform.h"
@@ -53,6 +53,23 @@ gfx::RectF RenderSurfaceImpl::DrawableContentRect() const {
return drawable_content_rect;
}
+SkColor RenderSurfaceImpl::GetDebugBorderColor() const {
+ return DebugColors::SurfaceBorderColor();
+}
+
+SkColor RenderSurfaceImpl::GetReplicaDebugBorderColor() const {
+ return DebugColors::SurfaceReplicaBorderColor();
+}
+
+float RenderSurfaceImpl::GetDebugBorderWidth() const {
+ return DebugColors::SurfaceBorderWidth(owning_layer_->layer_tree_impl());
+}
+
+float RenderSurfaceImpl::GetReplicaDebugBorderWidth() const {
+ return DebugColors::SurfaceReplicaBorderWidth(
+ owning_layer_->layer_tree_impl());
+}
+
int RenderSurfaceImpl::OwningLayerId() const {
return owning_layer_ ? owning_layer_->id() : 0;
}
@@ -132,72 +149,39 @@ void RenderSurfaceImpl::AppendRenderPasses(RenderPassSink* pass_sink) {
pass_sink->AppendRenderPass(pass.Pass());
}
-void RenderSurfaceImpl::AppendQuads(
- RenderPass* render_pass,
- const OcclusionTracker<LayerImpl>& occlusion_tracker,
- AppendQuadsData* append_quads_data,
- bool for_replica,
- RenderPassId render_pass_id) {
- DCHECK(!for_replica || owning_layer_->has_replica());
-
- const gfx::Transform& draw_transform =
- for_replica ? replica_draw_transform_ : draw_transform_;
+void RenderSurfaceImpl::AppendQuads(RenderPass* render_pass,
+ const gfx::Transform& draw_transform,
+ const Occlusion& occlusion_in_content_space,
+ SkColor debug_border_color,
+ float debug_border_width,
+ LayerImpl* mask_layer,
+ AppendQuadsData* append_quads_data,
+ RenderPassId render_pass_id) {
gfx::Rect visible_content_rect =
- occlusion_tracker.GetCurrentOcclusionForContributingSurface(
- draw_transform)
- .GetUnoccludedContentRect(content_rect_);
+ occlusion_in_content_space.GetUnoccludedContentRect(content_rect_);
if (visible_content_rect.IsEmpty())
return;
SharedQuadState* shared_quad_state =
render_pass->CreateAndAppendSharedQuadState();
- shared_quad_state->SetAll(draw_transform,
- content_rect_.size(),
- content_rect_,
- clip_rect_,
- is_clipped_,
- draw_opacity_,
+ shared_quad_state->SetAll(draw_transform, content_rect_.size(), content_rect_,
+ clip_rect_, is_clipped_, draw_opacity_,
owning_layer_->blend_mode(),
owning_layer_->sorting_context_id());
if (owning_layer_->ShowDebugBorders()) {
- SkColor color = for_replica ?
- DebugColors::SurfaceReplicaBorderColor() :
- DebugColors::SurfaceBorderColor();
- float width = for_replica ?
- DebugColors::SurfaceReplicaBorderWidth(
- owning_layer_->layer_tree_impl()) :
- DebugColors::SurfaceBorderWidth(
- owning_layer_->layer_tree_impl());
DebugBorderDrawQuad* debug_border_quad =
render_pass->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
- debug_border_quad->SetNew(
- shared_quad_state, content_rect_, visible_content_rect, color, width);
- }
-
- // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content
- // and its reflection, it's currently not possible to apply a separate mask to
- // the reflection layer or correctly handle opacity in reflections (opacity
- // must be applied after drawing both the layer and its reflection). The
- // solution is to introduce yet another RenderSurfaceImpl to draw the layer
- // and its reflection in. For now we only apply a separate reflection mask if
- // the contents don't have a mask of their own.
- LayerImpl* mask_layer = owning_layer_->mask_layer();
- if (mask_layer &&
- (!mask_layer->DrawsContent() || mask_layer->bounds().IsEmpty()))
- mask_layer = nullptr;
-
- if (!mask_layer && for_replica) {
- mask_layer = owning_layer_->replica_layer()->mask_layer();
- if (mask_layer &&
- (!mask_layer->DrawsContent() || mask_layer->bounds().IsEmpty()))
- mask_layer = nullptr;
+ debug_border_quad->SetNew(shared_quad_state, content_rect_,
+ visible_content_rect, debug_border_color,
+ debug_border_width);
}
ResourceProvider::ResourceId mask_resource_id = 0;
gfx::Size mask_texture_size;
gfx::Vector2dF mask_uv_scale;
- if (mask_layer) {
+ if (mask_layer && mask_layer->DrawsContent() &&
+ !mask_layer->bounds().IsEmpty()) {
mask_layer->GetContentsResourceId(&mask_resource_id, &mask_texture_size);
gfx::Vector2dF owning_layer_draw_scale =
MathUtil::ComputeTransform2dScaleComponents(
diff --git a/cc/layers/render_surface_impl.h b/cc/layers/render_surface_impl.h
index 3303e94..1cc2de8 100644
--- a/cc/layers/render_surface_impl.h
+++ b/cc/layers/render_surface_impl.h
@@ -22,8 +22,7 @@ namespace cc {
class DamageTracker;
class DelegatedRendererLayerImpl;
-template <typename LayerType>
-class OcclusionTracker;
+class Occlusion;
class RenderPassId;
class RenderPassSink;
class LayerImpl;
@@ -60,6 +59,12 @@ class CC_EXPORT RenderSurfaceImpl {
}
bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; }
+ SkColor GetDebugBorderColor() const;
+ SkColor GetReplicaDebugBorderColor() const;
+
+ float GetDebugBorderWidth() const;
+ float GetReplicaDebugBorderWidth() const;
+
void SetDrawTransform(const gfx::Transform& draw_transform) {
draw_transform_ = draw_transform;
}
@@ -136,9 +141,12 @@ class CC_EXPORT RenderSurfaceImpl {
void AppendRenderPasses(RenderPassSink* pass_sink);
void AppendQuads(RenderPass* render_pass,
- const OcclusionTracker<LayerImpl>& occlusion_tracker,
+ const gfx::Transform& draw_transform,
+ const Occlusion& occlusion_in_content_space,
+ SkColor debug_border_color,
+ float debug_border_width,
+ LayerImpl* mask_layer,
AppendQuadsData* append_quads_data,
- bool for_replica,
RenderPassId render_pass_id);
private:
diff --git a/cc/layers/render_surface_unittest.cc b/cc/layers/render_surface_unittest.cc
index 6afbdcb..81b15ad 100644
--- a/cc/layers/render_surface_unittest.cc
+++ b/cc/layers/render_surface_unittest.cc
@@ -102,23 +102,17 @@ TEST(RenderSurfaceTest, SanityCheckSurfaceCreatesCorrectSharedQuadState) {
gfx::Rect content_rect(0, 0, 50, 50);
gfx::Rect clip_rect(5, 5, 40, 40);
gfx::Transform origin;
-
origin.Translate(30, 40);
- render_surface->SetDrawTransform(origin);
render_surface->SetContentRect(content_rect);
render_surface->SetClipRect(clip_rect);
render_surface->SetDrawOpacity(1.f);
- MockOcclusionTracker<LayerImpl> occlusion_tracker;
scoped_ptr<RenderPass> render_pass = RenderPass::Create();
AppendQuadsData append_quads_data;
- bool for_replica = false;
- render_surface->AppendQuads(render_pass.get(),
- occlusion_tracker,
- &append_quads_data,
- for_replica,
+ render_surface->AppendQuads(render_pass.get(), origin, Occlusion(),
+ SK_ColorBLACK, 1.f, nullptr, &append_quads_data,
RenderPassId(2, 0));
ASSERT_EQ(1u, render_pass->shared_quad_state_list.size());
diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc
index 7e835b8..1256620 100644
--- a/cc/test/layer_test_common.cc
+++ b/cc/test/layer_test_common.cc
@@ -160,12 +160,12 @@ void LayerTestCommon::LayerImplTest::AppendSurfaceQuadsWithOcclusion(
render_pass_->quad_list.clear();
render_pass_->shared_quad_state_list.clear();
- occlusion_tracker_.set_occluded_target_rect_for_contributing_surface(
- occluded);
- bool for_replica = false;
- RenderPassId id(1, 1);
+
surface_impl->AppendQuads(
- render_pass_.get(), occlusion_tracker_, &data, for_replica, id);
+ render_pass_.get(), gfx::Transform(),
+ Occlusion(gfx::Transform(), SimpleEnclosedRegion(occluded),
+ SimpleEnclosedRegion()),
+ SK_ColorBLACK, 1.f, nullptr, &data, RenderPassId(1, 1));
}
} // namespace cc
diff --git a/cc/test/layer_test_common.h b/cc/test/layer_test_common.h
index 9b63f3f..dfd9729 100644
--- a/cc/test/layer_test_common.h
+++ b/cc/test/layer_test_common.h
@@ -9,7 +9,6 @@
#include "base/memory/scoped_ptr.h"
#include "cc/quads/render_pass.h"
#include "cc/test/fake_layer_tree_host.h"
-#include "cc/test/mock_occlusion_tracker.h"
#include "cc/trees/layer_tree_host_impl.h"
#define EXPECT_SET_NEEDS_COMMIT(expect, code_to_test) \
@@ -128,7 +127,6 @@ class LayerTestCommon {
scoped_ptr<FakeLayerTreeHost> host_;
scoped_ptr<LayerImpl> root_layer_impl_;
scoped_ptr<RenderPass> render_pass_;
- MockOcclusionTracker<LayerImpl> occlusion_tracker_;
};
};
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 86401a7..e3ca2ab 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -606,21 +606,42 @@ static void AppendQuadsForRenderSurfaceLayer(
const RenderPass* contributing_render_pass,
const OcclusionTracker<LayerImpl>& occlusion_tracker,
AppendQuadsData* append_quads_data) {
- bool is_replica = false;
- layer->render_surface()->AppendQuads(target_render_pass,
- occlusion_tracker,
- append_quads_data,
- is_replica,
- contributing_render_pass->id);
+ RenderSurfaceImpl* surface = layer->render_surface();
+ const gfx::Transform& draw_transform = surface->draw_transform();
+ const Occlusion& occlusion =
+ occlusion_tracker.GetCurrentOcclusionForContributingSurface(
+ draw_transform);
+ SkColor debug_border_color = surface->GetDebugBorderColor();
+ float debug_border_width = surface->GetDebugBorderWidth();
+ LayerImpl* mask_layer = layer->mask_layer();
+
+ surface->AppendQuads(target_render_pass, draw_transform, occlusion,
+ debug_border_color, debug_border_width, mask_layer,
+ append_quads_data, contributing_render_pass->id);
// Add replica after the surface so that it appears below the surface.
if (layer->has_replica()) {
- is_replica = true;
- layer->render_surface()->AppendQuads(target_render_pass,
- occlusion_tracker,
- append_quads_data,
- is_replica,
- contributing_render_pass->id);
+ const gfx::Transform& replica_draw_transform =
+ surface->replica_draw_transform();
+ const Occlusion& replica_occlusion =
+ occlusion_tracker.GetCurrentOcclusionForContributingSurface(
+ replica_draw_transform);
+ SkColor replica_debug_border_color = surface->GetReplicaDebugBorderColor();
+ float replica_debug_border_width = surface->GetReplicaDebugBorderWidth();
+ // TODO(danakj): By using the same RenderSurfaceImpl for both the
+ // content and its reflection, it's currently not possible to apply a
+ // separate mask to the reflection layer or correctly handle opacity in
+ // reflections (opacity must be applied after drawing both the layer and its
+ // reflection). The solution is to introduce yet another RenderSurfaceImpl
+ // to draw the layer and its reflection in. For now we only apply a separate
+ // reflection mask if the contents don't have a mask of their own.
+ LayerImpl* replica_mask_layer =
+ mask_layer ? mask_layer : layer->replica_layer()->mask_layer();
+
+ surface->AppendQuads(target_render_pass, replica_draw_transform,
+ replica_occlusion, replica_debug_border_color,
+ replica_debug_border_width, replica_mask_layer,
+ append_quads_data, contributing_render_pass->id);
}
}