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"
11 #include "cc/trees/layer_tree_impl.h"
15 FakeDelegatedRendererLayerImpl::FakeDelegatedRendererLayerImpl(
16 LayerTreeImpl
* tree_impl
,
18 : DelegatedRendererLayerImpl(tree_impl
, id
) {
21 FakeDelegatedRendererLayerImpl::~FakeDelegatedRendererLayerImpl() {}
23 scoped_ptr
<LayerImpl
> FakeDelegatedRendererLayerImpl::CreateLayerImpl(
24 LayerTreeImpl
* tree_impl
) {
25 return FakeDelegatedRendererLayerImpl::Create(tree_impl
, id());
28 static ResourceProvider::ResourceId
AddResourceToFrame(
29 ResourceProvider
* resource_provider
,
30 DelegatedFrameData
* frame
,
31 ResourceProvider::ResourceId resource_id
) {
32 TransferableResource resource
;
33 resource
.id
= resource_id
;
34 resource
.mailbox_holder
.texture_target
=
35 resource_provider
->TargetForTesting(resource_id
);
36 frame
->resource_list
.push_back(resource
);
40 ResourceProvider::ResourceIdSet
FakeDelegatedRendererLayerImpl::Resources()
42 ResourceProvider::ResourceIdSet set
;
43 ResourceProvider::ResourceIdArray array
;
44 array
= ResourcesForTesting();
45 for (size_t i
= 0; i
< array
.size(); ++i
)
50 void NoopReturnCallback(const ReturnedResourceArray
& returned
,
51 BlockingTaskRunner
* main_thread_task_runner
) {
54 void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses(
55 float device_scale_factor
,
56 const RenderPassList
& pass_list
) {
57 scoped_ptr
<DelegatedFrameData
> delegated_frame(new DelegatedFrameData
);
58 delegated_frame
->device_scale_factor
= device_scale_factor
;
59 RenderPass::CopyAll(pass_list
, &delegated_frame
->render_pass_list
);
61 ResourceProvider
* resource_provider
= layer_tree_impl()->resource_provider();
63 DrawQuad::ResourceIteratorCallback add_resource_to_frame_callback
=
64 base::Bind(&AddResourceToFrame
, resource_provider
, delegated_frame
.get());
65 for (const auto& pass
: delegated_frame
->render_pass_list
) {
66 for (const auto& quad
: pass
->quad_list
)
67 quad
->IterateResources(add_resource_to_frame_callback
);
70 CreateChildIdIfNeeded(base::Bind(&NoopReturnCallback
));
71 SetFrameData(delegated_frame
.get(), gfx::RectF());