summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 22:28:30 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 22:28:30 +0000
commit257492c171bcf774477475468b76b4ec4410a3fb (patch)
tree33227b70953fe5dedb6ab5ee4959e8b0165df0f5
parentf4126df56211740e179d466a1a1af61c9002b2fb (diff)
downloadchromium_src-257492c171bcf774477475468b76b4ec4410a3fb.zip
chromium_src-257492c171bcf774477475468b76b4ec4410a3fb.tar.gz
chromium_src-257492c171bcf774477475468b76b4ec4410a3fb.tar.bz2
cc: Make DelegatedRendererLayerImpl::SetRenderPasses() private.
This method was now public only for tests. SetFrameData() should be used instead. Implemented a SetFrameDataForRenderPasses() method on the FakeDelegatedRendererLayerImpl class. This class constructs a frame data out of a set of render passes, making a bogus set up TransferableResources for each resource in the render passes, and gives the whole frame to the real DelegatedRendererLayerImpl. Tested by all the delegated renderer layer tests. R=piman BUG=123444 Review URL: https://chromiumcodereview.appspot.com/12388082 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185997 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/delegated_renderer_layer_impl.cc18
-rw-r--r--cc/delegated_renderer_layer_impl.h8
-rw-r--r--cc/delegated_renderer_layer_impl_unittest.cc22
-rw-r--r--cc/layer_tree_host_unittest_context.cc14
-rw-r--r--cc/test/fake_delegated_renderer_layer_impl.cc29
-rw-r--r--cc/test/fake_delegated_renderer_layer_impl.h2
6 files changed, 64 insertions, 29 deletions
diff --git a/cc/delegated_renderer_layer_impl.cc b/cc/delegated_renderer_layer_impl.cc
index 156032a..e271b57 100644
--- a/cc/delegated_renderer_layer_impl.cc
+++ b/cc/delegated_renderer_layer_impl.cc
@@ -116,7 +116,7 @@ void DelegatedRendererLayerImpl::SetFrameData(
// Save the remapped quads on the layer. This steals the quads and render
// passes from the frame_data.
- SetRenderPasses(frame_data->render_pass_list);
+ SetRenderPasses(&frame_data->render_pass_list);
// Release the resources from the previous frame to prepare them for transport
// back to the child compositor.
@@ -142,22 +142,22 @@ void DelegatedRendererLayerImpl::SetDisplaySize(gfx::Size size) {
}
void DelegatedRendererLayerImpl::SetRenderPasses(
- ScopedPtrVector<RenderPass>& render_passes_in_draw_order) {
+ ScopedPtrVector<RenderPass>* render_passes_in_draw_order) {
gfx::RectF old_root_damage;
if (!render_passes_in_draw_order_.empty())
old_root_damage = render_passes_in_draw_order_.back()->damage_rect;
ClearRenderPasses();
- for (size_t i = 0; i < render_passes_in_draw_order.size(); ++i) {
+ for (size_t i = 0; i < render_passes_in_draw_order->size(); ++i) {
+ ScopedPtrVector<RenderPass>::iterator to_take =
+ render_passes_in_draw_order->begin() + i;
render_passes_index_by_id_.insert(
- std::pair<RenderPass::Id, int>(render_passes_in_draw_order[i]->id, i));
- scoped_ptr<RenderPass> passed_render_pass =
- render_passes_in_draw_order.take(
- render_passes_in_draw_order.begin() + i);
- render_passes_in_draw_order_.push_back(passed_render_pass.Pass());
+ std::pair<RenderPass::Id, int>((*to_take)->id, i));
+ scoped_ptr<RenderPass> taken_render_pass =
+ render_passes_in_draw_order->take(to_take);
+ render_passes_in_draw_order_.push_back(taken_render_pass.Pass());
}
- render_passes_in_draw_order.clear();
if (!render_passes_in_draw_order_.empty())
render_passes_in_draw_order_.back()->damage_rect.Union(old_root_damage);
diff --git a/cc/delegated_renderer_layer_impl.h b/cc/delegated_renderer_layer_impl.h
index cf23d8c..65f34e7 100644
--- a/cc/delegated_renderer_layer_impl.h
+++ b/cc/delegated_renderer_layer_impl.h
@@ -32,10 +32,6 @@ class CC_EXPORT DelegatedRendererLayerImpl : public LayerImpl {
virtual void appendQuads(
QuadSink& quad_sink, AppendQuadsData& append_quads_data) OVERRIDE;
- // TODO(danakj): Make private
- void SetRenderPasses(ScopedPtrVector<RenderPass>&);
- void ClearRenderPasses();
-
void AppendContributingRenderPasses(RenderPassSink* render_pass_sink);
virtual void SetFrameData(scoped_ptr<DelegatedFrameData> frame_data,
@@ -61,6 +57,10 @@ class CC_EXPORT DelegatedRendererLayerImpl : public LayerImpl {
void CreateChildIdIfNeeded();
void ClearChildId();
+ void SetRenderPasses(
+ ScopedPtrVector<RenderPass>* render_passes_in_draw_order);
+ void ClearRenderPasses();
+
RenderPass::Id ConvertDelegatedRenderPassId(
RenderPass::Id delegated_render_pass_id) const;
diff --git a/cc/delegated_renderer_layer_impl_unittest.cc b/cc/delegated_renderer_layer_impl_unittest.cc
index 417591a..94a59d7 100644
--- a/cc/delegated_renderer_layer_impl_unittest.cc
+++ b/cc/delegated_renderer_layer_impl_unittest.cc
@@ -13,6 +13,7 @@
#include "cc/single_thread_proxy.h"
#include "cc/solid_color_draw_quad.h"
#include "cc/solid_color_layer_impl.h"
+#include "cc/test/fake_delegated_renderer_layer_impl.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_layer_tree_host_impl_client.h"
#include "cc/test/fake_output_surface.h"
@@ -60,8 +61,8 @@ class DelegatedRendererLayerImplTestSimple
host_impl_->activeTree(), 2).PassAs<LayerImpl>();
scoped_ptr<LayerImpl> layer_after = SolidColorLayerImpl::create(
host_impl_->activeTree(), 3).PassAs<LayerImpl>();
- scoped_ptr<DelegatedRendererLayerImpl> delegated_renderer_layer =
- DelegatedRendererLayerImpl::Create(host_impl_->activeTree(), 4);
+ scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer =
+ FakeDelegatedRendererLayerImpl::Create(host_impl_->activeTree(), 4);
host_impl_->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
root_layer->setBounds(gfx::Size(100, 100));
@@ -106,7 +107,8 @@ class DelegatedRendererLayerImplTestSimple
gfx::Rect(0, 0, 8, 8),
gfx::Transform());
addRenderPassQuad(pass3, pass2);
- delegated_renderer_layer->SetRenderPasses(delegated_render_passes);
+ delegated_renderer_layer->SetFrameDataForRenderPasses(
+ &delegated_render_passes);
// The RenderPasses should be taken by the layer.
EXPECT_EQ(0u, delegated_render_passes.size());
@@ -456,8 +458,8 @@ class DelegatedRendererLayerImplTestTransform
void SetUpTest() {
scoped_ptr<LayerImpl> root_layer = LayerImpl::create(
host_impl_->activeTree(), 1);
- scoped_ptr<DelegatedRendererLayerImpl> delegated_renderer_layer =
- DelegatedRendererLayerImpl::Create(host_impl_->activeTree(), 2);
+ scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer =
+ FakeDelegatedRendererLayerImpl::Create(host_impl_->activeTree(), 2);
host_impl_->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
root_layer->setBounds(gfx::Size(100, 100));
@@ -565,7 +567,8 @@ class DelegatedRendererLayerImplTestTransform
color_quad->SetNew(shared_quad_state, gfx::Rect(10, 10, 10, 10), 4u);
quad_sink.append(color_quad.PassAs<DrawQuad>(), data);
- delegated_renderer_layer->SetRenderPasses(delegated_render_passes);
+ delegated_renderer_layer->SetFrameDataForRenderPasses(
+ &delegated_render_passes);
// The RenderPasses should be taken by the layer.
EXPECT_EQ(0u, delegated_render_passes.size());
@@ -852,8 +855,8 @@ class DelegatedRendererLayerImplTestClip
void SetUpTest() {
scoped_ptr<LayerImpl> root_layer =
LayerImpl::create(host_impl_->activeTree(), 1);
- scoped_ptr<DelegatedRendererLayerImpl> delegated_renderer_layer =
- DelegatedRendererLayerImpl::Create(host_impl_->activeTree(), 2);
+ scoped_ptr<FakeDelegatedRendererLayerImpl> delegated_renderer_layer =
+ FakeDelegatedRendererLayerImpl::Create(host_impl_->activeTree(), 2);
scoped_ptr<LayerImpl> clip_layer =
LayerImpl::create(host_impl_->activeTree(), 3);
scoped_ptr<LayerImpl> origin_layer =
@@ -957,7 +960,8 @@ class DelegatedRendererLayerImplTestClip
color_quad->SetNew(shared_quad_state, gfx::Rect(10, 10, 10, 10), 4u);
quad_sink.append(color_quad.PassAs<DrawQuad>(), data);
- delegated_renderer_layer->SetRenderPasses(delegated_render_passes);
+ delegated_renderer_layer->SetFrameDataForRenderPasses(
+ &delegated_render_passes);
// The RenderPasses should be taken by the layer.
EXPECT_EQ(0u, delegated_render_passes.size());
diff --git a/cc/layer_tree_host_unittest_context.cc b/cc/layer_tree_host_unittest_context.cc
index 42435c4..79f1f40 100644
--- a/cc/layer_tree_host_unittest_context.cc
+++ b/cc/layer_tree_host_unittest_context.cc
@@ -6,8 +6,6 @@
#include "base/basictypes.h"
#include "cc/content_layer.h"
-#include "cc/delegated_renderer_layer.h"
-#include "cc/delegated_renderer_layer_impl.h"
#include "cc/heads_up_display_layer.h"
#include "cc/io_surface_layer.h"
#include "cc/layer_impl.h"
@@ -20,6 +18,8 @@
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_content_layer_impl.h"
#include "cc/test/fake_context_provider.h"
+#include "cc/test/fake_delegated_renderer_layer.h"
+#include "cc/test/fake_delegated_renderer_layer_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_scrollbar_layer.h"
#include "cc/test/fake_scrollbar_theme_painter.h"
@@ -892,8 +892,8 @@ class LayerTreeHostContextTestDontUseLostResources :
root_->setAnchorPoint(gfx::PointF());
root_->setIsDrawable(true);
- scoped_refptr<DelegatedRendererLayer> delegated_ =
- DelegatedRendererLayer::Create();
+ scoped_refptr<FakeDelegatedRendererLayer> delegated_ =
+ FakeDelegatedRendererLayer::Create();
delegated_->setBounds(gfx::Size(10, 10));
delegated_->setAnchorPoint(gfx::PointF());
delegated_->setIsDrawable(true);
@@ -1008,10 +1008,10 @@ class LayerTreeHostContextTestDontUseLostResources :
pass_list.push_back(pass.PassAs<RenderPass>());
// First child is the delegated layer.
- DelegatedRendererLayerImpl* delegated_impl =
- static_cast<DelegatedRendererLayerImpl*>(
+ FakeDelegatedRendererLayerImpl* delegated_impl =
+ static_cast<FakeDelegatedRendererLayerImpl*>(
host_impl->rootLayer()->children()[0]);
- delegated_impl->SetRenderPasses(pass_list);
+ delegated_impl->SetFrameDataForRenderPasses(&pass_list);
EXPECT_TRUE(pass_list.empty());
color_video_frame_ = VideoFrame::CreateColorFrame(
diff --git a/cc/test/fake_delegated_renderer_layer_impl.cc b/cc/test/fake_delegated_renderer_layer_impl.cc
index 45e8dd2..3f39472 100644
--- a/cc/test/fake_delegated_renderer_layer_impl.cc
+++ b/cc/test/fake_delegated_renderer_layer_impl.cc
@@ -4,7 +4,9 @@
#include "cc/test/fake_delegated_renderer_layer_impl.h"
+#include "base/bind.h"
#include "cc/delegated_frame_data.h"
+#include "cc/draw_quad.h"
namespace cc {
@@ -14,4 +16,31 @@ FakeDelegatedRendererLayerImpl::FakeDelegatedRendererLayerImpl(
FakeDelegatedRendererLayerImpl::~FakeDelegatedRendererLayerImpl() {}
+static ResourceProvider::ResourceId AddResourceToFrame(
+ DelegatedFrameData* frame,
+ ResourceProvider::ResourceId resource_id) {
+ TransferableResource resource;
+ resource.id = resource_id;
+ frame->resource_list.push_back(resource);
+ return resource_id;
+}
+
+void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses(
+ ScopedPtrVector<RenderPass>* pass_list) {
+ scoped_ptr<DelegatedFrameData> delegated_frame(new DelegatedFrameData);
+ delegated_frame->render_pass_list.swap(*pass_list);
+
+ DrawQuad::ResourceIteratorCallback add_resource_to_frame_callback =
+ base::Bind(&AddResourceToFrame,
+ delegated_frame.get());
+ for (size_t i = 0; i < delegated_frame->render_pass_list.size(); ++i) {
+ RenderPass* pass = delegated_frame->render_pass_list[i];
+ for (size_t j = 0; j < pass->quad_list.size(); ++j)
+ pass->quad_list[j]->IterateResources(add_resource_to_frame_callback);
+ }
+
+ TransferableResourceArray resources_for_ack;
+ SetFrameData(delegated_frame.Pass(), gfx::RectF(), &resources_for_ack);
+}
+
} // namespace cc
diff --git a/cc/test/fake_delegated_renderer_layer_impl.h b/cc/test/fake_delegated_renderer_layer_impl.h
index 0e4efb8..42258b8 100644
--- a/cc/test/fake_delegated_renderer_layer_impl.h
+++ b/cc/test/fake_delegated_renderer_layer_impl.h
@@ -25,6 +25,8 @@ class FakeDelegatedRendererLayerImpl : public DelegatedRendererLayerImpl {
return ResourcesForTesting();
}
+ void SetFrameDataForRenderPasses(ScopedPtrVector<RenderPass>* pass_list);
+
protected:
FakeDelegatedRendererLayerImpl(LayerTreeImpl* tree_impl, int id);
};