| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/test/render_pass_test_common.h" | 5 #include "cc/test/render_pass_test_common.h" |
| 6 | 6 |
| 7 #include "cc/quads/checkerboard_draw_quad.h" | 7 #include "cc/quads/checkerboard_draw_quad.h" |
| 8 #include "cc/quads/debug_border_draw_quad.h" | 8 #include "cc/quads/debug_border_draw_quad.h" |
| 9 #include "cc/quads/io_surface_draw_quad.h" | 9 #include "cc/quads/io_surface_draw_quad.h" |
| 10 #include "cc/quads/render_pass_draw_quad.h" | 10 #include "cc/quads/render_pass_draw_quad.h" |
| 11 #include "cc/quads/shared_quad_state.h" | 11 #include "cc/quads/shared_quad_state.h" |
| 12 #include "cc/quads/solid_color_draw_quad.h" | 12 #include "cc/quads/solid_color_draw_quad.h" |
| 13 #include "cc/quads/stream_video_draw_quad.h" | 13 #include "cc/quads/stream_video_draw_quad.h" |
| 14 #include "cc/quads/texture_draw_quad.h" | 14 #include "cc/quads/texture_draw_quad.h" |
| 15 #include "cc/quads/tile_draw_quad.h" | 15 #include "cc/quads/tile_draw_quad.h" |
| 16 #include "cc/quads/yuv_video_draw_quad.h" | 16 #include "cc/quads/yuv_video_draw_quad.h" |
| 17 #include "cc/resources/resource_provider.h" | 17 #include "cc/resources/resource_provider.h" |
| 18 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 | 21 |
| 22 void TestRenderPass::AppendQuad(scoped_ptr<DrawQuad> quad) { | |
| 23 quad_list.push_back(quad.Pass()); | |
| 24 } | |
| 25 | |
| 26 void TestRenderPass::AppendOneOfEveryQuadType( | 22 void TestRenderPass::AppendOneOfEveryQuadType( |
| 27 ResourceProvider* resource_provider, | 23 ResourceProvider* resource_provider, |
| 28 RenderPass::Id child_pass) { | 24 RenderPass::Id child_pass) { |
| 29 gfx::Rect rect(0, 0, 100, 100); | 25 gfx::Rect rect(0, 0, 100, 100); |
| 30 gfx::Rect opaque_rect(10, 10, 80, 80); | 26 gfx::Rect opaque_rect(10, 10, 80, 80); |
| 31 gfx::Rect visible_rect(0, 0, 100, 100); | 27 gfx::Rect visible_rect(0, 0, 100, 100); |
| 32 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; | 28 const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 33 ResourceProvider::ResourceId resource1 = resource_provider->CreateResource( | 29 ResourceProvider::ResourceId resource1 = resource_provider->CreateResource( |
| 34 gfx::Size(45, 5), | 30 gfx::Size(45, 5), |
| 35 GL_CLAMP_TO_EDGE, | 31 GL_CLAMP_TO_EDGE, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 SharedQuadState* shared_state = this->CreateAndAppendSharedQuadState(); | 72 SharedQuadState* shared_state = this->CreateAndAppendSharedQuadState(); |
| 77 shared_state->SetAll(gfx::Transform(), | 73 shared_state->SetAll(gfx::Transform(), |
| 78 rect.size(), | 74 rect.size(), |
| 79 rect, | 75 rect, |
| 80 rect, | 76 rect, |
| 81 false, | 77 false, |
| 82 1, | 78 1, |
| 83 SkXfermode::kSrcOver_Mode, | 79 SkXfermode::kSrcOver_Mode, |
| 84 0); | 80 0); |
| 85 | 81 |
| 86 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = | 82 CheckerboardDrawQuad* checkerboard_quad = |
| 87 CheckerboardDrawQuad::Create(); | 83 this->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |
| 88 checkerboard_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED); | 84 checkerboard_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED); |
| 89 AppendQuad(checkerboard_quad.PassAs<DrawQuad>()); | |
| 90 | 85 |
| 91 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = | 86 DebugBorderDrawQuad* debug_border_quad = |
| 92 DebugBorderDrawQuad::Create(); | 87 this->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
| 93 debug_border_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED, 1); | 88 debug_border_quad->SetNew(shared_state, rect, visible_rect, SK_ColorRED, 1); |
| 94 AppendQuad(debug_border_quad.PassAs<DrawQuad>()); | |
| 95 | 89 |
| 96 scoped_ptr<IOSurfaceDrawQuad> io_surface_quad = IOSurfaceDrawQuad::Create(); | 90 IOSurfaceDrawQuad* io_surface_quad = |
| 91 this->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>(); |
| 97 io_surface_quad->SetNew(shared_state, | 92 io_surface_quad->SetNew(shared_state, |
| 98 rect, | 93 rect, |
| 99 opaque_rect, | 94 opaque_rect, |
| 100 visible_rect, | 95 visible_rect, |
| 101 gfx::Size(50, 50), | 96 gfx::Size(50, 50), |
| 102 resource7, | 97 resource7, |
| 103 IOSurfaceDrawQuad::FLIPPED); | 98 IOSurfaceDrawQuad::FLIPPED); |
| 104 AppendQuad(io_surface_quad.PassAs<DrawQuad>()); | |
| 105 | 99 |
| 106 if (child_pass.layer_id) { | 100 if (child_pass.layer_id) { |
| 107 scoped_ptr<RenderPassDrawQuad> render_pass_quad = | 101 RenderPassDrawQuad* render_pass_quad = |
| 108 RenderPassDrawQuad::Create(); | 102 this->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 109 render_pass_quad->SetNew(shared_state, | 103 render_pass_quad->SetNew(shared_state, |
| 110 rect, | 104 rect, |
| 111 visible_rect, | 105 visible_rect, |
| 112 child_pass, | 106 child_pass, |
| 113 false, | 107 false, |
| 114 resource5, | 108 resource5, |
| 115 rect, | 109 rect, |
| 116 gfx::RectF(), | 110 gfx::RectF(), |
| 117 FilterOperations(), | 111 FilterOperations(), |
| 118 FilterOperations()); | 112 FilterOperations()); |
| 119 AppendQuad(render_pass_quad.PassAs<DrawQuad>()); | |
| 120 | 113 |
| 121 scoped_ptr<RenderPassDrawQuad> render_pass_replica_quad = | 114 RenderPassDrawQuad* render_pass_replica_quad = |
| 122 RenderPassDrawQuad::Create(); | 115 this->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 123 render_pass_replica_quad->SetNew(shared_state, | 116 render_pass_replica_quad->SetNew(shared_state, |
| 124 rect, | 117 rect, |
| 125 visible_rect, | 118 visible_rect, |
| 126 child_pass, | 119 child_pass, |
| 127 true, | 120 true, |
| 128 resource5, | 121 resource5, |
| 129 rect, | 122 rect, |
| 130 gfx::RectF(), | 123 gfx::RectF(), |
| 131 FilterOperations(), | 124 FilterOperations(), |
| 132 FilterOperations()); | 125 FilterOperations()); |
| 133 AppendQuad(render_pass_replica_quad.PassAs<DrawQuad>()); | |
| 134 } | 126 } |
| 135 | 127 |
| 136 scoped_ptr<SolidColorDrawQuad> solid_color_quad = | 128 SolidColorDrawQuad* solid_color_quad = |
| 137 SolidColorDrawQuad::Create(); | 129 this->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 138 solid_color_quad->SetNew( | 130 solid_color_quad->SetNew( |
| 139 shared_state, rect, visible_rect, SK_ColorRED, false); | 131 shared_state, rect, visible_rect, SK_ColorRED, false); |
| 140 AppendQuad(solid_color_quad.PassAs<DrawQuad>()); | |
| 141 | 132 |
| 142 scoped_ptr<StreamVideoDrawQuad> stream_video_quad = | 133 StreamVideoDrawQuad* stream_video_quad = |
| 143 StreamVideoDrawQuad::Create(); | 134 this->CreateAndAppendDrawQuad<StreamVideoDrawQuad>(); |
| 144 stream_video_quad->SetNew(shared_state, | 135 stream_video_quad->SetNew(shared_state, |
| 145 rect, | 136 rect, |
| 146 opaque_rect, | 137 opaque_rect, |
| 147 visible_rect, | 138 visible_rect, |
| 148 resource6, | 139 resource6, |
| 149 gfx::Transform()); | 140 gfx::Transform()); |
| 150 AppendQuad(stream_video_quad.PassAs<DrawQuad>()); | |
| 151 | 141 |
| 152 scoped_ptr<TextureDrawQuad> texture_quad = TextureDrawQuad::Create(); | 142 TextureDrawQuad* texture_quad = |
| 143 this->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 153 texture_quad->SetNew(shared_state, | 144 texture_quad->SetNew(shared_state, |
| 154 rect, | 145 rect, |
| 155 opaque_rect, | 146 opaque_rect, |
| 156 visible_rect, | 147 visible_rect, |
| 157 resource1, | 148 resource1, |
| 158 false, | 149 false, |
| 159 gfx::PointF(0.f, 0.f), | 150 gfx::PointF(0.f, 0.f), |
| 160 gfx::PointF(1.f, 1.f), | 151 gfx::PointF(1.f, 1.f), |
| 161 SK_ColorTRANSPARENT, | 152 SK_ColorTRANSPARENT, |
| 162 vertex_opacity, | 153 vertex_opacity, |
| 163 false); | 154 false); |
| 164 AppendQuad(texture_quad.PassAs<DrawQuad>()); | |
| 165 | 155 |
| 166 scoped_ptr<TileDrawQuad> scaled_tile_quad = TileDrawQuad::Create(); | 156 TileDrawQuad* scaled_tile_quad = |
| 157 this->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 167 scaled_tile_quad->SetNew(shared_state, | 158 scaled_tile_quad->SetNew(shared_state, |
| 168 rect, | 159 rect, |
| 169 opaque_rect, | 160 opaque_rect, |
| 170 visible_rect, | 161 visible_rect, |
| 171 resource2, | 162 resource2, |
| 172 gfx::RectF(0, 0, 50, 50), | 163 gfx::RectF(0, 0, 50, 50), |
| 173 gfx::Size(50, 50), | 164 gfx::Size(50, 50), |
| 174 false); | 165 false); |
| 175 AppendQuad(scaled_tile_quad.PassAs<DrawQuad>()); | |
| 176 | 166 |
| 177 SharedQuadState* transformed_state = this->CreateAndAppendSharedQuadState(); | 167 SharedQuadState* transformed_state = this->CreateAndAppendSharedQuadState(); |
| 178 transformed_state->CopyFrom(shared_state); | 168 transformed_state->CopyFrom(shared_state); |
| 179 gfx::Transform rotation; | 169 gfx::Transform rotation; |
| 180 rotation.Rotate(45); | 170 rotation.Rotate(45); |
| 181 transformed_state->content_to_target_transform = | 171 transformed_state->content_to_target_transform = |
| 182 transformed_state->content_to_target_transform * rotation; | 172 transformed_state->content_to_target_transform * rotation; |
| 183 scoped_ptr<TileDrawQuad> transformed_tile_quad = TileDrawQuad::Create(); | 173 TileDrawQuad* transformed_tile_quad = |
| 174 this->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 184 transformed_tile_quad->SetNew(transformed_state, | 175 transformed_tile_quad->SetNew(transformed_state, |
| 185 rect, | 176 rect, |
| 186 opaque_rect, | 177 opaque_rect, |
| 187 visible_rect, | 178 visible_rect, |
| 188 resource3, | 179 resource3, |
| 189 gfx::RectF(0, 0, 100, 100), | 180 gfx::RectF(0, 0, 100, 100), |
| 190 gfx::Size(100, 100), | 181 gfx::Size(100, 100), |
| 191 false); | 182 false); |
| 192 AppendQuad(transformed_tile_quad.PassAs<DrawQuad>()); | |
| 193 | 183 |
| 194 SharedQuadState* shared_state2 = this->CreateAndAppendSharedQuadState(); | 184 SharedQuadState* shared_state2 = this->CreateAndAppendSharedQuadState(); |
| 195 shared_state->SetAll(gfx::Transform(), | 185 shared_state->SetAll(gfx::Transform(), |
| 196 rect.size(), | 186 rect.size(), |
| 197 rect, | 187 rect, |
| 198 rect, | 188 rect, |
| 199 false, | 189 false, |
| 200 1, | 190 1, |
| 201 SkXfermode::kSrcOver_Mode, | 191 SkXfermode::kSrcOver_Mode, |
| 202 0); | 192 0); |
| 203 | 193 |
| 204 scoped_ptr<TileDrawQuad> tile_quad = TileDrawQuad::Create(); | 194 TileDrawQuad* tile_quad = this->CreateAndAppendDrawQuad<TileDrawQuad>(); |
| 205 tile_quad->SetNew(shared_state2, | 195 tile_quad->SetNew(shared_state2, |
| 206 rect, | 196 rect, |
| 207 opaque_rect, | 197 opaque_rect, |
| 208 visible_rect, | 198 visible_rect, |
| 209 resource4, | 199 resource4, |
| 210 gfx::RectF(0, 0, 100, 100), | 200 gfx::RectF(0, 0, 100, 100), |
| 211 gfx::Size(100, 100), | 201 gfx::Size(100, 100), |
| 212 false); | 202 false); |
| 213 AppendQuad(tile_quad.PassAs<DrawQuad>()); | |
| 214 | 203 |
| 215 ResourceProvider::ResourceId plane_resources[4]; | 204 ResourceProvider::ResourceId plane_resources[4]; |
| 216 for (int i = 0; i < 4; ++i) { | 205 for (int i = 0; i < 4; ++i) { |
| 217 plane_resources[i] = | 206 plane_resources[i] = |
| 218 resource_provider->CreateResource( | 207 resource_provider->CreateResource( |
| 219 gfx::Size(20, 12), | 208 gfx::Size(20, 12), |
| 220 GL_CLAMP_TO_EDGE, | 209 GL_CLAMP_TO_EDGE, |
| 221 ResourceProvider::TextureUsageAny, | 210 ResourceProvider::TextureUsageAny, |
| 222 resource_provider->best_texture_format()); | 211 resource_provider->best_texture_format()); |
| 223 resource_provider->AllocateForTesting(plane_resources[i]); | 212 resource_provider->AllocateForTesting(plane_resources[i]); |
| 224 } | 213 } |
| 225 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; | 214 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::REC_601; |
| 226 scoped_ptr<YUVVideoDrawQuad> yuv_quad = YUVVideoDrawQuad::Create(); | 215 YUVVideoDrawQuad* yuv_quad = |
| 216 this->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
| 227 yuv_quad->SetNew(shared_state2, | 217 yuv_quad->SetNew(shared_state2, |
| 228 rect, | 218 rect, |
| 229 opaque_rect, | 219 opaque_rect, |
| 230 visible_rect, | 220 visible_rect, |
| 231 gfx::RectF(0, 0, 100, 100), | 221 gfx::RectF(0, 0, 100, 100), |
| 232 plane_resources[0], | 222 plane_resources[0], |
| 233 plane_resources[1], | 223 plane_resources[1], |
| 234 plane_resources[2], | 224 plane_resources[2], |
| 235 plane_resources[3], | 225 plane_resources[3], |
| 236 color_space); | 226 color_space); |
| 237 AppendQuad(yuv_quad.PassAs<DrawQuad>()); | |
| 238 } | 227 } |
| 239 | 228 |
| 240 } // namespace cc | 229 } // namespace cc |
| OLD | NEW |