Commit e8422c6b authored by samans's avatar samans Committed by Commit bot

Don't submit frames with no render passes in cc tests

Now that ForceReclaimResources is gone, frames with no render passes are
only submitted in unit tests. Also, since crrev.com/2835203002 we no
longer allow empty render pass lists to be sent over IPC. Fix the tests
and remove the checks for empty render pass lists in prod to simplify
code.

CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2855723002
Cr-Commit-Position: refs/heads/master@{#469545}
parent 2c899c79
...@@ -120,10 +120,11 @@ void CompositorFrameSinkSupport::SubmitCompositorFrame( ...@@ -120,10 +120,11 @@ void CompositorFrameSinkSupport::SubmitCompositorFrame(
const LocalSurfaceId& local_surface_id, const LocalSurfaceId& local_surface_id,
CompositorFrame frame) { CompositorFrame frame) {
DCHECK(surface_factory_); DCHECK(surface_factory_);
++ack_pending_count_;
DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number, DCHECK_GE(frame.metadata.begin_frame_ack.sequence_number,
BeginFrameArgs::kStartingFrameNumber); BeginFrameArgs::kStartingFrameNumber);
DCHECK(!frame.render_pass_list.empty());
++ack_pending_count_;
// |has_damage| is not transmitted. // |has_damage| is not transmitted.
frame.metadata.begin_frame_ack.has_damage = true; frame.metadata.begin_frame_ack.has_damage = true;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "cc/surfaces/surface_id.h" #include "cc/surfaces/surface_id.h"
#include "cc/surfaces/surface_manager.h" #include "cc/surfaces/surface_manager.h"
#include "cc/test/begin_frame_args_test.h" #include "cc/test/begin_frame_args_test.h"
#include "cc/test/compositor_frame_helpers.h"
#include "cc/test/fake_external_begin_frame_source.h" #include "cc/test/fake_external_begin_frame_source.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -23,7 +24,6 @@ using testing::_; ...@@ -23,7 +24,6 @@ using testing::_;
using testing::Eq; using testing::Eq;
namespace cc { namespace cc {
namespace test {
namespace { namespace {
constexpr FrameSinkId kDisplayFrameSink(2, 0); constexpr FrameSinkId kDisplayFrameSink(2, 0);
...@@ -78,7 +78,7 @@ SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { ...@@ -78,7 +78,7 @@ SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) {
CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces, CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces,
std::vector<SurfaceId> referenced_surfaces, std::vector<SurfaceId> referenced_surfaces,
TransferableResourceArray resource_list) { TransferableResourceArray resource_list) {
CompositorFrame compositor_frame; CompositorFrame compositor_frame = test::MakeCompositorFrame();
compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, true); compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, true);
compositor_frame.metadata.embedded_surfaces = std::move(embedded_surfaces); compositor_frame.metadata.embedded_surfaces = std::move(embedded_surfaces);
compositor_frame.metadata.referenced_surfaces = compositor_frame.metadata.referenced_surfaces =
...@@ -1321,5 +1321,4 @@ TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) { ...@@ -1321,5 +1321,4 @@ TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) {
EXPECT_TRUE(parent_surface()->HasActiveFrame()); EXPECT_TRUE(parent_surface()->HasActiveFrame());
} }
} // namespace test
} // namespace cc } // namespace cc
...@@ -283,19 +283,17 @@ bool Display::DrawAndSwap() { ...@@ -283,19 +283,17 @@ bool Display::DrawAndSwap() {
gfx::Size surface_size; gfx::Size surface_size;
bool have_damage = false; bool have_damage = false;
if (!frame.render_pass_list.empty()) { RenderPass& last_render_pass = *frame.render_pass_list.back();
RenderPass& last_render_pass = *frame.render_pass_list.back(); if (last_render_pass.output_rect.size() != current_surface_size_ &&
if (last_render_pass.output_rect.size() != current_surface_size_ && last_render_pass.damage_rect == last_render_pass.output_rect &&
last_render_pass.damage_rect == last_render_pass.output_rect && !current_surface_size_.IsEmpty()) {
!current_surface_size_.IsEmpty()) { // Resize the output rect to the current surface size so that we won't
// Resize the output rect to the current surface size so that we won't // skip the draw and so that the GL swap won't stretch the output.
// skip the draw and so that the GL swap won't stretch the output. last_render_pass.output_rect.set_size(current_surface_size_);
last_render_pass.output_rect.set_size(current_surface_size_); last_render_pass.damage_rect = last_render_pass.output_rect;
last_render_pass.damage_rect = last_render_pass.output_rect;
}
surface_size = last_render_pass.output_rect.size();
have_damage = !last_render_pass.damage_rect.size().IsEmpty();
} }
surface_size = last_render_pass.output_rect.size();
have_damage = !last_render_pass.damage_rect.size().IsEmpty();
bool size_matches = surface_size == current_surface_size_; bool size_matches = surface_size == current_surface_size_;
if (!size_matches) if (!size_matches)
......
...@@ -84,8 +84,7 @@ void Surface::QueueFrame(CompositorFrame frame, ...@@ -84,8 +84,7 @@ void Surface::QueueFrame(CompositorFrame frame,
void Surface::RequestCopyOfOutput( void Surface::RequestCopyOfOutput(
std::unique_ptr<CopyOutputRequest> copy_request) { std::unique_ptr<CopyOutputRequest> copy_request) {
if (!active_frame_data_ || if (!active_frame_data_) {
active_frame_data_->frame.render_pass_list.empty()) {
copy_request->SendEmptyResult(); copy_request->SendEmptyResult();
return; return;
} }
...@@ -167,8 +166,7 @@ void Surface::ActivateFrame(FrameData frame_data) { ...@@ -167,8 +166,7 @@ void Surface::ActivateFrame(FrameData frame_data) {
// Save root pass copy requests. // Save root pass copy requests.
std::vector<std::unique_ptr<CopyOutputRequest>> old_copy_requests; std::vector<std::unique_ptr<CopyOutputRequest>> old_copy_requests;
if (active_frame_data_ && if (active_frame_data_) {
!active_frame_data_->frame.render_pass_list.empty()) {
std::swap(old_copy_requests, std::swap(old_copy_requests,
active_frame_data_->frame.render_pass_list.back()->copy_requests); active_frame_data_->frame.render_pass_list.back()->copy_requests);
} }
...@@ -184,10 +182,7 @@ void Surface::ActivateFrame(FrameData frame_data) { ...@@ -184,10 +182,7 @@ void Surface::ActivateFrame(FrameData frame_data) {
for (auto& copy_request : old_copy_requests) for (auto& copy_request : old_copy_requests)
RequestCopyOfOutput(std::move(copy_request)); RequestCopyOfOutput(std::move(copy_request));
// Empty frames shouldn't be drawn and shouldn't contribute damage, so don't ++frame_index_;
// increment frame index for them.
if (!active_frame_data_->frame.render_pass_list.empty())
++frame_index_;
previous_frame_surface_id_ = surface_id(); previous_frame_surface_id_ = surface_id();
......
...@@ -625,14 +625,12 @@ gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id, ...@@ -625,14 +625,12 @@ gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id,
provider_ ? provider_->GetChildToParentMap(child_id) : empty_map; provider_ ? provider_->GetChildToParentMap(child_id) : empty_map;
CHECK(debug_weak_this.get()); CHECK(debug_weak_this.get());
if (!frame.render_pass_list.empty()) { int remapped_pass_id =
int remapped_pass_id = RemapPassId(frame.render_pass_list.back()->id, surface_id);
RemapPassId(frame.render_pass_list.back()->id, surface_id); if (in_moved_pixel_surface)
if (in_moved_pixel_surface) moved_pixel_passes_.insert(remapped_pass_id);
moved_pixel_passes_.insert(remapped_pass_id); if (parent_pass_id)
if (parent_pass_id) render_pass_dependencies_[parent_pass_id].insert(remapped_pass_id);
render_pass_dependencies_[parent_pass_id].insert(remapped_pass_id);
}
struct SurfaceInfo { struct SurfaceInfo {
SurfaceInfo(const SurfaceId& id, SurfaceInfo(const SurfaceId& id,
...@@ -722,12 +720,10 @@ gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id, ...@@ -722,12 +720,10 @@ gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id,
gfx::Rect damage_rect; gfx::Rect damage_rect;
gfx::Rect full_damage; gfx::Rect full_damage;
if (!frame.render_pass_list.empty()) { RenderPass* last_pass = frame.render_pass_list.back().get();
RenderPass* last_pass = frame.render_pass_list.back().get(); full_damage = last_pass->output_rect;
full_damage = last_pass->output_rect; damage_rect =
damage_rect = DamageRectForSurface(surface, *last_pass, last_pass->output_rect);
DamageRectForSurface(surface, *last_pass, last_pass->output_rect);
}
// Avoid infinite recursion by adding current surface to // Avoid infinite recursion by adding current surface to
// referenced_surfaces_. // referenced_surfaces_.
......
...@@ -84,16 +84,6 @@ class SurfaceAggregatorTest : public testing::Test { ...@@ -84,16 +84,6 @@ class SurfaceAggregatorTest : public testing::Test {
SurfaceAggregator aggregator_; SurfaceAggregator aggregator_;
}; };
TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
LocalSurfaceId local_surface_id(7, base::UnguessableToken::Create());
SurfaceId one_id(kArbitraryRootFrameSinkId, local_surface_id);
support_->SubmitCompositorFrame(local_surface_id,
test::MakeCompositorFrame());
CompositorFrame frame = aggregator_.Aggregate(one_id);
EXPECT_TRUE(frame.render_pass_list.empty());
}
class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
public: public:
explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect) explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect)
...@@ -148,7 +138,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { ...@@ -148,7 +138,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
void SubmitPassListAsFrame(CompositorFrameSinkSupport* support, void SubmitPassListAsFrame(CompositorFrameSinkSupport* support,
const LocalSurfaceId& local_surface_id, const LocalSurfaceId& local_surface_id,
RenderPassList* pass_list) { RenderPassList* pass_list) {
CompositorFrame frame = test::MakeCompositorFrame(); CompositorFrame frame = test::MakeEmptyCompositorFrame();
pass_list->swap(frame.render_pass_list); pass_list->swap(frame.render_pass_list);
support->SubmitCompositorFrame(local_surface_id, std::move(frame)); support->SubmitCompositorFrame(local_surface_id, std::move(frame));
...@@ -166,7 +156,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { ...@@ -166,7 +156,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
void QueuePassAsFrame(std::unique_ptr<RenderPass> pass, void QueuePassAsFrame(std::unique_ptr<RenderPass> pass,
const LocalSurfaceId& local_surface_id, const LocalSurfaceId& local_surface_id,
CompositorFrameSinkSupport* support) { CompositorFrameSinkSupport* support) {
CompositorFrame child_frame = test::MakeCompositorFrame(); CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
child_frame.render_pass_list.push_back(std::move(pass)); child_frame.render_pass_list.push_back(std::move(pass));
support->SubmitCompositorFrame(local_surface_id, std::move(child_frame)); support->SubmitCompositorFrame(local_surface_id, std::move(child_frame));
...@@ -584,7 +574,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) { ...@@ -584,7 +574,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
test::Pass(root_quads, arraysize(root_quads), 1), test::Pass(root_quads, arraysize(root_quads), 1),
test::Pass(root_quads2, arraysize(root_quads2), 2)}; test::Pass(root_quads2, arraysize(root_quads2), 2)};
{ {
CompositorFrame frame = test::MakeCompositorFrame(); CompositorFrame frame = test::MakeEmptyCompositorFrame();
AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes)); arraysize(root_passes));
frame.render_pass_list[0]->copy_requests.push_back(std::move(copy_request)); frame.render_pass_list[0]->copy_requests.push_back(std::move(copy_request));
...@@ -671,7 +661,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { ...@@ -671,7 +661,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
test::Pass(parent_quads, arraysize(parent_quads))}; test::Pass(parent_quads, arraysize(parent_quads))};
{ {
CompositorFrame frame = test::MakeCompositorFrame(); CompositorFrame frame = test::MakeEmptyCompositorFrame();
AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes, AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), parent_passes,
arraysize(parent_passes)); arraysize(parent_passes));
...@@ -687,7 +677,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) { ...@@ -687,7 +677,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))}; test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
{ {
CompositorFrame frame = test::MakeCompositorFrame(); CompositorFrame frame = test::MakeEmptyCompositorFrame();
AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, AddPasses(&frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes)); arraysize(root_passes));
...@@ -1254,7 +1244,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { ...@@ -1254,7 +1244,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
test::Pass(child_quads[1], arraysize(child_quads[1]), test::Pass(child_quads[1], arraysize(child_quads[1]),
child_pass_id[1])}; child_pass_id[1])};
CompositorFrame child_frame = test::MakeCompositorFrame(); CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
child_passes, arraysize(child_passes)); child_passes, arraysize(child_passes));
...@@ -1286,7 +1276,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { ...@@ -1286,7 +1276,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
test::Pass(middle_quads, arraysize(middle_quads)), test::Pass(middle_quads, arraysize(middle_quads)),
}; };
CompositorFrame middle_frame = test::MakeCompositorFrame(); CompositorFrame middle_frame = test::MakeEmptyCompositorFrame();
AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&middle_frame.render_pass_list, gfx::Rect(SurfaceSize()),
middle_passes, arraysize(middle_passes)); middle_passes, arraysize(middle_passes));
...@@ -1310,7 +1300,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) { ...@@ -1310,7 +1300,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
test::Pass(secondary_quads, arraysize(secondary_quads)), test::Pass(secondary_quads, arraysize(secondary_quads)),
test::Pass(root_quads, arraysize(root_quads))}; test::Pass(root_quads, arraysize(root_quads))};
CompositorFrame root_frame = test::MakeCompositorFrame(); CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes)); arraysize(root_passes));
...@@ -1414,7 +1404,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { ...@@ -1414,7 +1404,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
test::Pass child_passes[] = { test::Pass child_passes[] = {
test::Pass(child_quads, arraysize(child_quads), 1)}; test::Pass(child_quads, arraysize(child_quads), 1)};
CompositorFrame child_frame = test::MakeCompositorFrame(); CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
child_passes, arraysize(child_passes)); child_passes, arraysize(child_passes));
...@@ -1436,7 +1426,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { ...@@ -1436,7 +1426,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
// Parent surface is only used to test if the transform is applied correctly // Parent surface is only used to test if the transform is applied correctly
// to the child surface's damage. // to the child surface's damage.
CompositorFrame parent_surface_frame = test::MakeCompositorFrame(); CompositorFrame parent_surface_frame = test::MakeEmptyCompositorFrame();
AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&parent_surface_frame.render_pass_list, gfx::Rect(SurfaceSize()),
parent_surface_passes, arraysize(parent_surface_passes)); parent_surface_passes, arraysize(parent_surface_passes));
...@@ -1454,7 +1444,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { ...@@ -1454,7 +1444,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
test::Pass(root_surface_quads, arraysize(root_surface_quads), 1), test::Pass(root_surface_quads, arraysize(root_surface_quads), 1),
test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
CompositorFrame root_frame = test::MakeCompositorFrame(); CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes)); arraysize(root_passes));
...@@ -1480,7 +1470,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { ...@@ -1480,7 +1470,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize()))); aggregated_pass_list[1]->damage_rect.Contains(gfx::Rect(SurfaceSize())));
{ {
CompositorFrame child_frame = test::MakeCompositorFrame(); CompositorFrame child_frame = test::MakeEmptyCompositorFrame();
AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&child_frame.render_pass_list, gfx::Rect(SurfaceSize()),
child_passes, arraysize(child_passes)); child_passes, arraysize(child_passes));
...@@ -1509,7 +1499,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { ...@@ -1509,7 +1499,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
} }
{ {
CompositorFrame root_frame = test::MakeCompositorFrame(); CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
root_passes, arraysize(root_passes)); root_passes, arraysize(root_passes));
...@@ -1523,7 +1513,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) { ...@@ -1523,7 +1513,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
} }
{ {
CompositorFrame root_frame = test::MakeCompositorFrame(); CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
root_passes, arraysize(root_passes)); root_passes, arraysize(root_passes));
...@@ -1589,7 +1579,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { ...@@ -1589,7 +1579,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
test::Pass root_passes[] = { test::Pass root_passes[] = {
test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; test::Pass(root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
CompositorFrame root_frame = test::MakeCompositorFrame(); CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes, AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), root_passes,
arraysize(root_passes)); arraysize(root_passes));
...@@ -1622,7 +1612,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) { ...@@ -1622,7 +1612,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
test::Pass root_passes[] = {test::Pass( test::Pass root_passes[] = {test::Pass(
root_render_pass_quads, arraysize(root_render_pass_quads), 2)}; root_render_pass_quads, arraysize(root_render_pass_quads), 2)};
CompositorFrame root_frame = test::MakeCompositorFrame(); CompositorFrame root_frame = test::MakeEmptyCompositorFrame();
AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()), AddPasses(&root_frame.render_pass_list, gfx::Rect(SurfaceSize()),
root_passes, arraysize(root_passes)); root_passes, arraysize(root_passes));
...@@ -1967,7 +1957,7 @@ void SubmitCompositorFrameWithResources(ResourceId* resource_ids, ...@@ -1967,7 +1957,7 @@ void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
SurfaceId child_id, SurfaceId child_id,
CompositorFrameSinkSupport* support, CompositorFrameSinkSupport* support,
SurfaceId surface_id) { SurfaceId surface_id) {
CompositorFrame frame = test::MakeCompositorFrame(); CompositorFrame frame = test::MakeEmptyCompositorFrame();
std::unique_ptr<RenderPass> pass = RenderPass::Create(); std::unique_ptr<RenderPass> pass = RenderPass::Create();
pass->id = 1; pass->id = 1;
SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
...@@ -2051,7 +2041,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) { ...@@ -2051,7 +2041,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create()); LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create());
SurfaceId surface_id(support->frame_sink_id(), local_surface_id); SurfaceId surface_id(support->frame_sink_id(), local_surface_id);
CompositorFrame frame = test::MakeCompositorFrame(); CompositorFrame frame = test::MakeEmptyCompositorFrame();
std::unique_ptr<RenderPass> pass = RenderPass::Create(); std::unique_ptr<RenderPass> pass = RenderPass::Create();
pass->id = 1; pass->id = 1;
TransferableResource resource; TransferableResource resource;
...@@ -2222,7 +2212,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) { ...@@ -2222,7 +2212,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
surface1_id, SurfaceDrawQuadType::PRIMARY, nullptr); surface1_id, SurfaceDrawQuadType::PRIMARY, nullptr);
pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
CompositorFrame frame = test::MakeCompositorFrame(); CompositorFrame frame = test::MakeEmptyCompositorFrame();
frame.render_pass_list.push_back(std::move(pass)); frame.render_pass_list.push_back(std::move(pass));
support2->SubmitCompositorFrame(local_frame2_id, std::move(frame)); support2->SubmitCompositorFrame(local_frame2_id, std::move(frame));
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "cc/surfaces/surface_info.h" #include "cc/surfaces/surface_info.h"
#include "cc/surfaces/surface_manager.h" #include "cc/surfaces/surface_manager.h"
#include "cc/surfaces/surface_resource_holder_client.h" #include "cc/surfaces/surface_resource_holder_client.h"
#include "cc/test/compositor_frame_helpers.h"
#include "cc/test/fake_surface_resource_holder_client.h" #include "cc/test/fake_surface_resource_holder_client.h"
#include "cc/test/scheduler_test_common.h" #include "cc/test/scheduler_test_common.h"
#include "cc/test/stub_surface_factory_client.h" #include "cc/test/stub_surface_factory_client.h"
...@@ -82,7 +83,7 @@ class SurfaceFactoryTest : public testing::Test, public SurfaceObserver { ...@@ -82,7 +83,7 @@ class SurfaceFactoryTest : public testing::Test, public SurfaceObserver {
void SubmitCompositorFrameWithResources(ResourceId* resource_ids, void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
size_t num_resource_ids) { size_t num_resource_ids) {
CompositorFrame frame; CompositorFrame frame = test::MakeCompositorFrame();
for (size_t i = 0u; i < num_resource_ids; ++i) { for (size_t i = 0u; i < num_resource_ids; ++i) {
TransferableResource resource; TransferableResource resource;
resource.id = resource_ids[i]; resource.id = resource_ids[i];
...@@ -451,18 +452,6 @@ TEST_F(SurfaceFactoryTest, ResourceLifetime) { ...@@ -451,18 +452,6 @@ TEST_F(SurfaceFactoryTest, ResourceLifetime) {
} }
} }
TEST_F(SurfaceFactoryTest, BlankNoIndexIncrement) {
LocalSurfaceId local_surface_id(6, kArbitraryToken);
SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id);
factory_->SubmitCompositorFrame(local_surface_id, CompositorFrame(),
SurfaceFactory::DrawCallback(),
SurfaceFactory::WillDrawCallback());
Surface* surface = manager_.GetSurfaceForId(surface_id);
ASSERT_NE(nullptr, surface);
EXPECT_EQ(2, surface->frame_index());
EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id);
}
void CreateSurfaceDrawCallback(SurfaceFactory* factory, void CreateSurfaceDrawCallback(SurfaceFactory* factory,
uint32_t* execute_count) { uint32_t* execute_count) {
LocalSurfaceId new_id(7, base::UnguessableToken::Create()); LocalSurfaceId new_id(7, base::UnguessableToken::Create());
......
...@@ -260,9 +260,6 @@ const RenderPass* SurfaceHittest::GetRenderPassForSurfaceById( ...@@ -260,9 +260,6 @@ const RenderPass* SurfaceHittest::GetRenderPassForSurfaceById(
return nullptr; return nullptr;
const CompositorFrame& surface_frame = surface->GetActiveFrame(); const CompositorFrame& surface_frame = surface->GetActiveFrame();
if (surface_frame.render_pass_list.empty())
return nullptr;
if (!render_pass_id) if (!render_pass_id)
return surface_frame.render_pass_list.back().get(); return surface_frame.render_pass_list.back().get();
......
...@@ -498,19 +498,15 @@ void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id, ...@@ -498,19 +498,15 @@ void SurfaceManager::SurfaceReferencesToStringImpl(const SurfaceId& surface_id,
if (surface->HasPendingFrame()) { if (surface->HasPendingFrame()) {
// This provides the surface size from the root render pass. // This provides the surface size from the root render pass.
const CompositorFrame& frame = surface->GetPendingFrame(); const CompositorFrame& frame = surface->GetPendingFrame();
if (!frame.render_pass_list.empty()) { *str << " pending "
*str << " pending " << frame.render_pass_list.back()->output_rect.size().ToString();
<< frame.render_pass_list.back()->output_rect.size().ToString();
}
} }
if (surface->HasActiveFrame()) { if (surface->HasActiveFrame()) {
// This provides the surface size from the root render pass. // This provides the surface size from the root render pass.
const CompositorFrame& frame = surface->GetActiveFrame(); const CompositorFrame& frame = surface->GetActiveFrame();
if (!frame.render_pass_list.empty()) { *str << " active "
*str << " active " << frame.render_pass_list.back()->output_rect.size().ToString();
<< frame.render_pass_list.back()->output_rect.size().ToString();
}
} }
} else { } else {
*str << surface_id; *str << surface_id;
......
...@@ -40,10 +40,7 @@ class FrameSinkManagerClient; ...@@ -40,10 +40,7 @@ class FrameSinkManagerClient;
class Surface; class Surface;
class SurfaceFactory; class SurfaceFactory;
class SurfaceFactoryClient; class SurfaceFactoryClient;
namespace test {
class CompositorFrameSinkSupportTest; class CompositorFrameSinkSupportTest;
}
class CC_SURFACES_EXPORT SurfaceManager { class CC_SURFACES_EXPORT SurfaceManager {
public: public:
...@@ -172,7 +169,7 @@ class CC_SURFACES_EXPORT SurfaceManager { ...@@ -172,7 +169,7 @@ class CC_SURFACES_EXPORT SurfaceManager {
} }
private: private:
friend class test::CompositorFrameSinkSupportTest; friend class CompositorFrameSinkSupportTest;
friend class SurfaceManagerRefTest; friend class SurfaceManagerRefTest;
using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>; using SurfaceIdSet = std::unordered_set<SurfaceId, SurfaceIdHash>;
......
...@@ -9,10 +9,19 @@ namespace cc { ...@@ -9,10 +9,19 @@ namespace cc {
namespace test { namespace test {
CompositorFrame MakeCompositorFrame() { CompositorFrame MakeCompositorFrame() {
CompositorFrame frame = MakeEmptyCompositorFrame();
std::unique_ptr<RenderPass> pass = RenderPass::Create();
pass->SetNew(1, gfx::Rect(0, 0, 20, 20), gfx::Rect(), gfx::Transform());
frame.render_pass_list.push_back(std::move(pass));
return frame;
}
CompositorFrame MakeEmptyCompositorFrame() {
CompositorFrame frame; CompositorFrame frame;
frame.metadata.begin_frame_ack.source_id = BeginFrameArgs::kManualSourceId; frame.metadata.begin_frame_ack.source_id = BeginFrameArgs::kManualSourceId;
frame.metadata.begin_frame_ack.sequence_number = frame.metadata.begin_frame_ack.sequence_number =
BeginFrameArgs::kStartingFrameNumber; BeginFrameArgs::kStartingFrameNumber;
frame.metadata.device_scale_factor = 1;
return frame; return frame;
} }
......
...@@ -11,8 +11,13 @@ class CompositorFrame; ...@@ -11,8 +11,13 @@ class CompositorFrame;
namespace test { namespace test {
// Creates a valid CompositorFrame.
CompositorFrame MakeCompositorFrame(); CompositorFrame MakeCompositorFrame();
// Creates a CompositorFrame that will be valid once its render_pass_list is
// initialized.
CompositorFrame MakeEmptyCompositorFrame();
} // namespace test } // namespace test
} // namespace cc } // namespace cc
......
...@@ -52,13 +52,7 @@ void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { ...@@ -52,13 +52,7 @@ void FakeCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
last_sent_frame_.reset(new CompositorFrame(std::move(frame))); last_sent_frame_.reset(new CompositorFrame(std::move(frame)));
++num_sent_frames_; ++num_sent_frames_;
if (!last_sent_frame_->render_pass_list.empty()) { last_swap_rect_ = last_sent_frame_->render_pass_list.back()->damage_rect;
last_swap_rect_ = last_sent_frame_->render_pass_list.back()->damage_rect;
last_swap_rect_valid_ = true;
} else {
last_swap_rect_ = gfx::Rect();
last_swap_rect_valid_ = false;
}
resources_held_by_parent_.insert(resources_held_by_parent_.end(), resources_held_by_parent_.insert(resources_held_by_parent_.end(),
last_sent_frame_->resource_list.begin(), last_sent_frame_->resource_list.begin(),
......
...@@ -76,7 +76,6 @@ class FakeCompositorFrameSink : public CompositorFrameSink { ...@@ -76,7 +76,6 @@ class FakeCompositorFrameSink : public CompositorFrameSink {
} }
gfx::Rect last_swap_rect() const { gfx::Rect last_swap_rect() const {
DCHECK(last_swap_rect_valid_);
return last_swap_rect_; return last_swap_rect_;
} }
...@@ -93,7 +92,6 @@ class FakeCompositorFrameSink : public CompositorFrameSink { ...@@ -93,7 +92,6 @@ class FakeCompositorFrameSink : public CompositorFrameSink {
std::unique_ptr<CompositorFrame> last_sent_frame_; std::unique_ptr<CompositorFrame> last_sent_frame_;
size_t num_sent_frames_ = 0; size_t num_sent_frames_ = 0;
TransferableResourceArray resources_held_by_parent_; TransferableResourceArray resources_held_by_parent_;
bool last_swap_rect_valid_ = false;
gfx::Rect last_swap_rect_; gfx::Rect last_swap_rect_;
private: private:
......
...@@ -81,9 +81,7 @@ void ClientCompositorFrameSink::SubmitCompositorFrame( ...@@ -81,9 +81,7 @@ void ClientCompositorFrameSink::SubmitCompositorFrame(
DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber,
frame.metadata.begin_frame_ack.sequence_number); frame.metadata.begin_frame_ack.sequence_number);
gfx::Size frame_size = last_submitted_frame_size_; gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
if (!frame.render_pass_list.empty())
frame_size = frame.render_pass_list.back()->output_rect.size();
if (!enable_surface_synchronization_ && if (!enable_surface_synchronization_ &&
(!local_surface_id_.is_valid() || (!local_surface_id_.is_valid() ||
frame_size != last_submitted_frame_size_)) { frame_size != last_submitted_frame_size_)) {
......
...@@ -51,9 +51,7 @@ void DisplayClientCompositorFrameSink::SubmitCompositorFrame( ...@@ -51,9 +51,7 @@ void DisplayClientCompositorFrameSink::SubmitCompositorFrame(
DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber, DCHECK_LE(cc::BeginFrameArgs::kStartingFrameNumber,
frame.metadata.begin_frame_ack.sequence_number); frame.metadata.begin_frame_ack.sequence_number);
gfx::Size frame_size = last_submitted_frame_size_; gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size();
if (!frame.render_pass_list.empty())
frame_size = frame.render_pass_list.back()->output_rect.size();
if (!local_surface_id_.is_valid() || if (!local_surface_id_.is_valid() ||
frame_size != last_submitted_frame_size_) { frame_size != last_submitted_frame_size_) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment