| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/layer_tree_pixel_test.h" | 5 #include "cc/test/layer_tree_pixel_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "cc/base/switches.h" | 9 #include "cc/base/switches.h" |
| 10 #include "cc/layers/solid_color_layer.h" | 10 #include "cc/layers/solid_color_layer.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 112 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 113 if (cmd->HasSwitch(switches::kCCRebaselinePixeltests)) | 113 if (cmd->HasSwitch(switches::kCCRebaselinePixeltests)) |
| 114 EXPECT_TRUE(WritePNGFile(*result_bitmap_, ref_file_path, true)); | 114 EXPECT_TRUE(WritePNGFile(*result_bitmap_, ref_file_path, true)); |
| 115 | 115 |
| 116 EXPECT_TRUE(MatchesPNGFile(*result_bitmap_, | 116 EXPECT_TRUE(MatchesPNGFile(*result_bitmap_, |
| 117 ref_file_path, | 117 ref_file_path, |
| 118 *pixel_comparator_)); | 118 *pixel_comparator_)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 scoped_refptr<SolidColorLayer> LayerTreePixelTest::CreateSolidColorLayer( | 121 scoped_refptr<SolidColorLayer> LayerTreePixelTest::CreateSolidColorLayer( |
| 122 gfx::Rect rect, SkColor color) { | 122 const gfx::Rect& rect, SkColor color) { |
| 123 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create(); | 123 scoped_refptr<SolidColorLayer> layer = SolidColorLayer::Create(); |
| 124 layer->SetIsDrawable(true); | 124 layer->SetIsDrawable(true); |
| 125 layer->SetAnchorPoint(gfx::PointF()); | 125 layer->SetAnchorPoint(gfx::PointF()); |
| 126 layer->SetBounds(rect.size()); | 126 layer->SetBounds(rect.size()); |
| 127 layer->SetPosition(rect.origin()); | 127 layer->SetPosition(rect.origin()); |
| 128 layer->SetBackgroundColor(color); | 128 layer->SetBackgroundColor(color); |
| 129 return layer; | 129 return layer; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void LayerTreePixelTest::EndTest() { | 132 void LayerTreePixelTest::EndTest() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 143 void LayerTreePixelTest::TryEndTest() { | 143 void LayerTreePixelTest::TryEndTest() { |
| 144 if (!result_bitmap_) | 144 if (!result_bitmap_) |
| 145 return; | 145 return; |
| 146 if (pending_texture_mailbox_callbacks_) | 146 if (pending_texture_mailbox_callbacks_) |
| 147 return; | 147 return; |
| 148 LayerTreeTest::EndTest(); | 148 LayerTreeTest::EndTest(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 scoped_refptr<SolidColorLayer> LayerTreePixelTest:: | 151 scoped_refptr<SolidColorLayer> LayerTreePixelTest:: |
| 152 CreateSolidColorLayerWithBorder( | 152 CreateSolidColorLayerWithBorder( |
| 153 gfx::Rect rect, SkColor color, int border_width, SkColor border_color) { | 153 const gfx::Rect& rect, SkColor color, |
| 154 int border_width, SkColor border_color) { |
| 154 scoped_refptr<SolidColorLayer> layer = CreateSolidColorLayer(rect, color); | 155 scoped_refptr<SolidColorLayer> layer = CreateSolidColorLayer(rect, color); |
| 155 scoped_refptr<SolidColorLayer> border_top = CreateSolidColorLayer( | 156 scoped_refptr<SolidColorLayer> border_top = CreateSolidColorLayer( |
| 156 gfx::Rect(0, 0, rect.width(), border_width), border_color); | 157 gfx::Rect(0, 0, rect.width(), border_width), border_color); |
| 157 scoped_refptr<SolidColorLayer> border_left = CreateSolidColorLayer( | 158 scoped_refptr<SolidColorLayer> border_left = CreateSolidColorLayer( |
| 158 gfx::Rect(0, | 159 gfx::Rect(0, |
| 159 border_width, | 160 border_width, |
| 160 border_width, | 161 border_width, |
| 161 rect.height() - border_width * 2), | 162 rect.height() - border_width * 2), |
| 162 border_color); | 163 border_color); |
| 163 scoped_refptr<SolidColorLayer> border_right = | 164 scoped_refptr<SolidColorLayer> border_right = |
| 164 CreateSolidColorLayer(gfx::Rect(rect.width() - border_width, | 165 CreateSolidColorLayer(gfx::Rect(rect.width() - border_width, |
| 165 border_width, | 166 border_width, |
| 166 border_width, | 167 border_width, |
| 167 rect.height() - border_width * 2), | 168 rect.height() - border_width * 2), |
| 168 border_color); | 169 border_color); |
| 169 scoped_refptr<SolidColorLayer> border_bottom = CreateSolidColorLayer( | 170 scoped_refptr<SolidColorLayer> border_bottom = CreateSolidColorLayer( |
| 170 gfx::Rect(0, rect.height() - border_width, rect.width(), border_width), | 171 gfx::Rect(0, rect.height() - border_width, rect.width(), border_width), |
| 171 border_color); | 172 border_color); |
| 172 layer->AddChild(border_top); | 173 layer->AddChild(border_top); |
| 173 layer->AddChild(border_left); | 174 layer->AddChild(border_left); |
| 174 layer->AddChild(border_right); | 175 layer->AddChild(border_right); |
| 175 layer->AddChild(border_bottom); | 176 layer->AddChild(border_bottom); |
| 176 return layer; | 177 return layer; |
| 177 } | 178 } |
| 178 | 179 |
| 179 scoped_refptr<TextureLayer> LayerTreePixelTest::CreateTextureLayer( | 180 scoped_refptr<TextureLayer> LayerTreePixelTest::CreateTextureLayer( |
| 180 gfx::Rect rect, const SkBitmap& bitmap) { | 181 const gfx::Rect& rect, const SkBitmap& bitmap) { |
| 181 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(NULL); | 182 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(NULL); |
| 182 layer->SetIsDrawable(true); | 183 layer->SetIsDrawable(true); |
| 183 layer->SetAnchorPoint(gfx::PointF()); | 184 layer->SetAnchorPoint(gfx::PointF()); |
| 184 layer->SetBounds(rect.size()); | 185 layer->SetBounds(rect.size()); |
| 185 layer->SetPosition(rect.origin()); | 186 layer->SetPosition(rect.origin()); |
| 186 | 187 |
| 187 TextureMailbox texture_mailbox; | 188 TextureMailbox texture_mailbox; |
| 188 scoped_ptr<SingleReleaseCallback> release_callback; | 189 scoped_ptr<SingleReleaseCallback> release_callback; |
| 189 CopyBitmapToTextureMailboxAsTexture( | 190 CopyBitmapToTextureMailboxAsTexture( |
| 190 bitmap, &texture_mailbox, &release_callback); | 191 bitmap, &texture_mailbox, &release_callback); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 | 371 |
| 371 *texture_mailbox = TextureMailbox(mailbox, sync_point); | 372 *texture_mailbox = TextureMailbox(mailbox, sync_point); |
| 372 *release_callback = SingleReleaseCallback::Create( | 373 *release_callback = SingleReleaseCallback::Create( |
| 373 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, | 374 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, |
| 374 base::Unretained(this), | 375 base::Unretained(this), |
| 375 base::Passed(&context), | 376 base::Passed(&context), |
| 376 texture_id)); | 377 texture_id)); |
| 377 } | 378 } |
| 378 | 379 |
| 379 } // namespace cc | 380 } // namespace cc |
| OLD | NEW |