blob: 8f4c1048c86334516f55db6a6e82f08f559c9def (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/test/fake_delegated_renderer_layer_impl.h"
#include "base/bind.h"
#include "cc/output/delegated_frame_data.h"
#include "cc/quads/draw_quad.h"
#include "cc/resources/returned_resource.h"
#include "cc/trees/layer_tree_impl.h"
namespace cc {
FakeDelegatedRendererLayerImpl::FakeDelegatedRendererLayerImpl(
LayerTreeImpl* tree_impl, int id)
: DelegatedRendererLayerImpl(tree_impl, id) {}
FakeDelegatedRendererLayerImpl::~FakeDelegatedRendererLayerImpl() {}
scoped_ptr<LayerImpl> FakeDelegatedRendererLayerImpl::CreateLayerImpl(
LayerTreeImpl* tree_impl) {
return FakeDelegatedRendererLayerImpl::Create(
tree_impl, id()).PassAs<LayerImpl>();
}
static ResourceProvider::ResourceId AddResourceToFrame(
ResourceProvider* resource_provider,
DelegatedFrameData* frame,
ResourceProvider::ResourceId resource_id) {
TransferableResource resource;
resource.id = resource_id;
resource.mailbox_holder.texture_target =
resource_provider->TargetForTesting(resource_id);
frame->resource_list.push_back(resource);
return resource_id;
}
ResourceProvider::ResourceIdSet FakeDelegatedRendererLayerImpl::Resources()
const {
ResourceProvider::ResourceIdSet set;
ResourceProvider::ResourceIdArray array;
array = ResourcesForTesting();
for (size_t i = 0; i < array.size(); ++i)
set.insert(array[i]);
return set;
}
void NoopReturnCallback(const ReturnedResourceArray& returned) {}
void FakeDelegatedRendererLayerImpl::SetFrameDataForRenderPasses(
ScopedPtrVector<RenderPass>* pass_list) {
scoped_ptr<DelegatedFrameData> delegated_frame(new DelegatedFrameData);
delegated_frame->render_pass_list.swap(*pass_list);
ResourceProvider* resource_provider = layer_tree_impl()->resource_provider();
DrawQuad::ResourceIteratorCallback add_resource_to_frame_callback =
base::Bind(&AddResourceToFrame, resource_provider, delegated_frame.get());
for (size_t i = 0; i < delegated_frame->render_pass_list.size(); ++i) {
RenderPass* pass = delegated_frame->render_pass_list[i];
for (size_t j = 0; j < pass->quad_list.size(); ++j)
pass->quad_list[j]->IterateResources(add_resource_to_frame_callback);
}
CreateChildIdIfNeeded(base::Bind(&NoopReturnCallback));
SetFrameData(delegated_frame.get(), gfx::RectF());
}
} // namespace cc
|