Adds initial key systems support for Chromecast.
[chromium-blink-merge.git] / cc / test / fake_delegated_renderer_layer_impl.cc
blobc440d748214f50c6e985b82407bd57cc70a31f51
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,
17 int id)
18 : DelegatedRendererLayerImpl(tree_impl, id) {
21 FakeDelegatedRendererLayerImpl::~FakeDelegatedRendererLayerImpl() {}
23 scoped_ptr<LayerImpl> FakeDelegatedRendererLayerImpl::CreateLayerImpl(
24 LayerTreeImpl* tree_impl) {
25 return FakeDelegatedRendererLayerImpl::Create(
26 tree_impl, id()).PassAs<LayerImpl>();
29 static ResourceProvider::ResourceId AddResourceToFrame(
30 ResourceProvider* resource_provider,
31 DelegatedFrameData* frame,
32 ResourceProvider::ResourceId resource_id) {
33 TransferableResource resource;
34 resource.id = resource_id;
35 resource.mailbox_holder.texture_target =
36 resource_provider->TargetForTesting(resource_id);
37 frame->resource_list.push_back(resource);
38 return resource_id;
41 ResourceProvider::ResourceIdSet FakeDelegatedRendererLayerImpl::Resources()
42 const {
43 ResourceProvider::ResourceIdSet set;
44 ResourceProvider::ResourceIdArray array;
45 array = ResourcesForTesting();
46 for (size_t i = 0; i < array.size(); ++i)
47 set.insert(array[i]);
48 return set;
51 void NoopReturnCallback(const ReturnedResourceArray& returned,
52 BlockingTaskRunner* main_thread_task_runner) {
55 void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses(
56 float device_scale_factor,
57 RenderPassList* pass_list) {
58 scoped_ptr<DelegatedFrameData> delegated_frame(new DelegatedFrameData);
59 delegated_frame->device_scale_factor = device_scale_factor;
60 delegated_frame->render_pass_list.swap(*pass_list);
62 ResourceProvider* resource_provider = layer_tree_impl()->resource_provider();
64 DrawQuad::ResourceIteratorCallback add_resource_to_frame_callback =
65 base::Bind(&AddResourceToFrame, resource_provider, delegated_frame.get());
66 for (size_t i = 0; i < delegated_frame->render_pass_list.size(); ++i) {
67 RenderPass* pass = delegated_frame->render_pass_list[i];
68 for (size_t j = 0; j < pass->quad_list.size(); ++j)
69 pass->quad_list[j]->IterateResources(add_resource_to_frame_callback);
72 CreateChildIdIfNeeded(base::Bind(&NoopReturnCallback));
73 SetFrameData(delegated_frame.get(), gfx::RectF());
76 } // namespace cc