1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/test/fake_delegated_renderer_layer_impl.h"
8 #include "cc/output/delegated_frame_data.h"
9 #include "cc/quads/draw_quad.h"
10 #include "cc/resources/returned_resource.h"
14 FakeDelegatedRendererLayerImpl::FakeDelegatedRendererLayerImpl(
15 LayerTreeImpl
* tree_impl
, int id
)
16 : DelegatedRendererLayerImpl(tree_impl
, id
) {}
18 FakeDelegatedRendererLayerImpl::~FakeDelegatedRendererLayerImpl() {}
20 scoped_ptr
<LayerImpl
> FakeDelegatedRendererLayerImpl::CreateLayerImpl(
21 LayerTreeImpl
* tree_impl
) {
22 return FakeDelegatedRendererLayerImpl::Create(
23 tree_impl
, id()).PassAs
<LayerImpl
>();
26 static ResourceProvider::ResourceId
AddResourceToFrame(
27 DelegatedFrameData
* frame
,
28 ResourceProvider::ResourceId resource_id
) {
29 TransferableResource resource
;
30 resource
.id
= resource_id
;
31 frame
->resource_list
.push_back(resource
);
35 void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses(
36 ScopedPtrVector
<RenderPass
>* pass_list
) {
37 scoped_ptr
<DelegatedFrameData
> delegated_frame(new DelegatedFrameData
);
38 delegated_frame
->render_pass_list
.swap(*pass_list
);
40 DrawQuad::ResourceIteratorCallback add_resource_to_frame_callback
=
41 base::Bind(&AddResourceToFrame
,
42 delegated_frame
.get());
43 for (size_t i
= 0; i
< delegated_frame
->render_pass_list
.size(); ++i
) {
44 RenderPass
* pass
= delegated_frame
->render_pass_list
[i
];
45 for (size_t j
= 0; j
< pass
->quad_list
.size(); ++j
)
46 pass
->quad_list
[j
]->IterateResources(add_resource_to_frame_callback
);
49 ReturnedResourceArray resources_for_ack
;
50 SetFrameData(delegated_frame
.Pass(), gfx::RectF());
51 CollectUnusedResources(&resources_for_ack
);