Fix for ISpy relocation.
[chromium-blink-merge.git] / cc / test / fake_delegated_renderer_layer_impl.cc
blob8f4c1048c86334516f55db6a6e82f08f559c9def
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"
7 #include "base/bind.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"
13 namespace cc {
15 FakeDelegatedRendererLayerImpl::FakeDelegatedRendererLayerImpl(
16 LayerTreeImpl* tree_impl, int id)
17 : DelegatedRendererLayerImpl(tree_impl, id) {}
19 FakeDelegatedRendererLayerImpl::~FakeDelegatedRendererLayerImpl() {}
21 scoped_ptr<LayerImpl> FakeDelegatedRendererLayerImpl::CreateLayerImpl(
22 LayerTreeImpl* tree_impl) {
23 return FakeDelegatedRendererLayerImpl::Create(
24 tree_impl, id()).PassAs<LayerImpl>();
27 static ResourceProvider::ResourceId AddResourceToFrame(
28 ResourceProvider* resource_provider,
29 DelegatedFrameData* frame,
30 ResourceProvider::ResourceId resource_id) {
31 TransferableResource resource;
32 resource.id = resource_id;
33 resource.mailbox_holder.texture_target =
34 resource_provider->TargetForTesting(resource_id);
35 frame->resource_list.push_back(resource);
36 return resource_id;
39 ResourceProvider::ResourceIdSet FakeDelegatedRendererLayerImpl::Resources()
40 const {
41 ResourceProvider::ResourceIdSet set;
42 ResourceProvider::ResourceIdArray array;
43 array = ResourcesForTesting();
44 for (size_t i = 0; i < array.size(); ++i)
45 set.insert(array[i]);
46 return set;
49 void NoopReturnCallback(const ReturnedResourceArray& returned) {}
51 void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses(
52 ScopedPtrVector<RenderPass>* pass_list) {
53 scoped_ptr<DelegatedFrameData> delegated_frame(new DelegatedFrameData);
54 delegated_frame->render_pass_list.swap(*pass_list);
56 ResourceProvider* resource_provider = layer_tree_impl()->resource_provider();
58 DrawQuad::ResourceIteratorCallback add_resource_to_frame_callback =
59 base::Bind(&AddResourceToFrame, resource_provider, delegated_frame.get());
60 for (size_t i = 0; i < delegated_frame->render_pass_list.size(); ++i) {
61 RenderPass* pass = delegated_frame->render_pass_list[i];
62 for (size_t j = 0; j < pass->quad_list.size(); ++j)
63 pass->quad_list[j]->IterateResources(add_resource_to_frame_callback);
66 CreateChildIdIfNeeded(base::Bind(&NoopReturnCallback));
67 SetFrameData(delegated_frame.get(), gfx::RectF());
70 } // namespace cc