add a use_alsa gyp setting
[chromium-blink-merge.git] / cc / test / render_pass_test_utils.cc
blobbda83dd6e96e5b7b25b9d25fca139d2f0c1fd9e7
1 // Copyright 2012 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/render_pass_test_utils.h"
7 #include "cc/append_quads_data.h"
8 #include "cc/quad_sink.h"
9 #include "cc/render_pass_draw_quad.h"
10 #include "cc/shared_quad_state.h"
11 #include "cc/solid_color_draw_quad.h"
12 #include "cc/test/mock_quad_culler.h"
13 #include "cc/test/render_pass_test_common.h"
14 #include "ui/gfx/rect.h"
16 namespace cc {
18 TestRenderPass* addRenderPass(RenderPassList& passList,
19 RenderPass::Id id,
20 const gfx::Rect& outputRect,
21 const gfx::Transform& rootTransform) {
22 scoped_ptr<TestRenderPass> pass(TestRenderPass::Create());
23 pass->SetNew(id, outputRect, outputRect, rootTransform);
24 TestRenderPass* saved = pass.get();
25 passList.push_back(pass.PassAs<RenderPass>());
26 return saved;
29 SolidColorDrawQuad* addQuad(TestRenderPass* pass,
30 const gfx::Rect& rect,
31 SkColor color) {
32 MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list);
33 AppendQuadsData data(pass->id);
34 SharedQuadState* sharedState =
35 quadSink.useSharedQuadState(SharedQuadState::Create());
36 sharedState->SetAll(gfx::Transform(), rect, rect, false, 1);
37 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
38 quad->SetNew(sharedState, rect, color);
39 SolidColorDrawQuad* quadPtr = quad.get();
40 quadSink.append(quad.PassAs<DrawQuad>(), data);
41 return quadPtr;
44 SolidColorDrawQuad* addClippedQuad(TestRenderPass* pass,
45 const gfx::Rect& rect,
46 SkColor color) {
47 MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list);
48 AppendQuadsData data(pass->id);
49 SharedQuadState* sharedState =
50 quadSink.useSharedQuadState(SharedQuadState::Create());
51 sharedState->SetAll(gfx::Transform(), rect, rect, true, 1);
52 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
53 quad->SetNew(sharedState, rect, color);
54 SolidColorDrawQuad* quadPtr = quad.get();
55 quadSink.append(quad.PassAs<DrawQuad>(), data);
56 return quadPtr;
59 void addRenderPassQuad(TestRenderPass* toPass,
60 TestRenderPass* contributingPass) {
61 MockQuadCuller quadSink(toPass->quad_list, toPass->shared_quad_state_list);
62 AppendQuadsData data(toPass->id);
63 gfx::Rect outputRect = contributingPass->output_rect;
64 SharedQuadState* sharedState =
65 quadSink.useSharedQuadState(SharedQuadState::Create());
66 sharedState->SetAll(gfx::Transform(), outputRect, outputRect, false, 1);
67 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create();
68 quad->SetNew(sharedState, outputRect, contributingPass->id, false, 0,
69 outputRect, gfx::RectF(), WebKit::WebFilterOperations(),
70 skia::RefPtr<SkImageFilter>(), WebKit::WebFilterOperations());
71 quadSink.append(quad.PassAs<DrawQuad>(), data);
74 } // namespace cc