[Do not revert] Roll-back V8 to version 4.4.63.
[chromium-blink-merge.git] / cc / test / fake_delegated_renderer_layer_impl.cc
blob1154a0e0b58b9d6a5b52c4a6911a770cb02e12fa
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(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);
37 return resource_id;
40 ResourceProvider::ResourceIdSet FakeDelegatedRendererLayerImpl::Resources()
41 const {
42 return ResourcesForTesting();
45 void NoopReturnCallback(const ReturnedResourceArray& returned,
46 BlockingTaskRunner* main_thread_task_runner) {
49 void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses(
50 float device_scale_factor,
51 const RenderPassList& pass_list) {
52 scoped_ptr<DelegatedFrameData> delegated_frame(new DelegatedFrameData);
53 delegated_frame->device_scale_factor = device_scale_factor;
54 RenderPass::CopyAll(pass_list, &delegated_frame->render_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 (const auto& pass : delegated_frame->render_pass_list) {
61 for (const auto& quad : pass->quad_list)
62 quad->IterateResources(add_resource_to_frame_callback);
65 CreateChildIdIfNeeded(base::Bind(&NoopReturnCallback));
66 SetFrameData(delegated_frame.get(), gfx::RectF());
69 } // namespace cc