| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 #include "cc/layers/solid_color_layer.h" | 6 #include "cc/layers/solid_color_layer.h" |
| 7 #include "cc/layers/texture_layer.h" | 7 #include "cc/layers/texture_layer.h" |
| 8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
| 10 #include "cc/test/fake_picture_layer.h" | 10 #include "cc/test/fake_picture_layer.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 void RunReadbackTestWithReadbackTarget(PixelTestType type, | 54 void RunReadbackTestWithReadbackTarget(PixelTestType type, |
| 55 ReadbackType readback_type, | 55 ReadbackType readback_type, |
| 56 scoped_refptr<Layer> content_root, | 56 scoped_refptr<Layer> content_root, |
| 57 Layer* target, | 57 Layer* target, |
| 58 base::FilePath file_name) { | 58 base::FilePath file_name) { |
| 59 readback_type_ = readback_type; | 59 readback_type_ = readback_type; |
| 60 RunPixelTestWithReadbackTarget(type, content_root, target, file_name); | 60 RunPixelTestWithReadbackTarget(type, content_root, target, file_name); |
| 61 } | 61 } |
| 62 | 62 |
| 63 scoped_ptr<CopyOutputRequest> CreateCopyOutputRequest() override { | 63 std::unique_ptr<CopyOutputRequest> CreateCopyOutputRequest() override { |
| 64 scoped_ptr<CopyOutputRequest> request; | 64 std::unique_ptr<CopyOutputRequest> request; |
| 65 | 65 |
| 66 if (readback_type_ == READBACK_BITMAP) { | 66 if (readback_type_ == READBACK_BITMAP) { |
| 67 request = CopyOutputRequest::CreateBitmapRequest( | 67 request = CopyOutputRequest::CreateBitmapRequest( |
| 68 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, | 68 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, |
| 69 base::Unretained(this))); | 69 base::Unretained(this))); |
| 70 } else { | 70 } else { |
| 71 DCHECK_EQ(readback_type_, READBACK_DEFAULT); | 71 DCHECK_EQ(readback_type_, READBACK_DEFAULT); |
| 72 if (test_type_ == PIXEL_TEST_SOFTWARE) { | 72 if (test_type_ == PIXEL_TEST_SOFTWARE) { |
| 73 request = CopyOutputRequest::CreateRequest( | 73 request = CopyOutputRequest::CreateRequest( |
| 74 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, | 74 base::Bind(&LayerTreeHostReadbackPixelTest::ReadbackResultAsBitmap, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 97 | 97 |
| 98 void DidCommitAndDrawFrame() override { | 98 void DidCommitAndDrawFrame() override { |
| 99 if (insert_copy_request_after_frame_count_ == | 99 if (insert_copy_request_after_frame_count_ == |
| 100 layer_tree_host()->source_frame_number()) { | 100 layer_tree_host()->source_frame_number()) { |
| 101 Layer* const target = | 101 Layer* const target = |
| 102 readback_target_ ? readback_target_ : layer_tree_host()->root_layer(); | 102 readback_target_ ? readback_target_ : layer_tree_host()->root_layer(); |
| 103 target->RequestCopyOfOutput(CreateCopyOutputRequest()); | 103 target->RequestCopyOfOutput(CreateCopyOutputRequest()); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ReadbackResultAsBitmap(scoped_ptr<CopyOutputResult> result) { | 107 void ReadbackResultAsBitmap(std::unique_ptr<CopyOutputResult> result) { |
| 108 EXPECT_TRUE(task_runner_provider()->IsMainThread()); | 108 EXPECT_TRUE(task_runner_provider()->IsMainThread()); |
| 109 EXPECT_TRUE(result->HasBitmap()); | 109 EXPECT_TRUE(result->HasBitmap()); |
| 110 result_bitmap_ = result->TakeBitmap(); | 110 result_bitmap_ = result->TakeBitmap(); |
| 111 EndTest(); | 111 EndTest(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void ReadbackResultAsTexture(scoped_ptr<CopyOutputResult> result) { | 114 void ReadbackResultAsTexture(std::unique_ptr<CopyOutputResult> result) { |
| 115 EXPECT_TRUE(task_runner_provider()->IsMainThread()); | 115 EXPECT_TRUE(task_runner_provider()->IsMainThread()); |
| 116 EXPECT_TRUE(result->HasTexture()); | 116 EXPECT_TRUE(result->HasTexture()); |
| 117 | 117 |
| 118 TextureMailbox texture_mailbox; | 118 TextureMailbox texture_mailbox; |
| 119 scoped_ptr<SingleReleaseCallback> release_callback; | 119 std::unique_ptr<SingleReleaseCallback> release_callback; |
| 120 result->TakeTexture(&texture_mailbox, &release_callback); | 120 result->TakeTexture(&texture_mailbox, &release_callback); |
| 121 EXPECT_TRUE(texture_mailbox.IsValid()); | 121 EXPECT_TRUE(texture_mailbox.IsValid()); |
| 122 EXPECT_TRUE(texture_mailbox.IsTexture()); | 122 EXPECT_TRUE(texture_mailbox.IsTexture()); |
| 123 | 123 |
| 124 scoped_ptr<SkBitmap> bitmap = | 124 std::unique_ptr<SkBitmap> bitmap = |
| 125 CopyTextureMailboxToBitmap(result->size(), texture_mailbox); | 125 CopyTextureMailboxToBitmap(result->size(), texture_mailbox); |
| 126 release_callback->Run(gpu::SyncToken(), false); | 126 release_callback->Run(gpu::SyncToken(), false); |
| 127 | 127 |
| 128 ReadbackResultAsBitmap( | 128 ReadbackResultAsBitmap( |
| 129 CopyOutputResult::CreateBitmapResult(std::move(bitmap))); | 129 CopyOutputResult::CreateBitmapResult(std::move(bitmap))); |
| 130 } | 130 } |
| 131 | 131 |
| 132 ReadbackType readback_type_; | 132 ReadbackType readback_type_; |
| 133 gfx::Rect copy_subrect_; | 133 gfx::Rect copy_subrect_; |
| 134 int insert_copy_request_after_frame_count_; | 134 int insert_copy_request_after_frame_count_; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 void IgnoreReadbackResult(scoped_ptr<CopyOutputResult> result) { | 137 void IgnoreReadbackResult(std::unique_ptr<CopyOutputResult> result) {} |
| 138 } | |
| 139 | 138 |
| 140 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackRootLayer) { | 139 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackRootLayer) { |
| 141 scoped_refptr<SolidColorLayer> background = | 140 scoped_refptr<SolidColorLayer> background = |
| 142 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | 141 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 143 | 142 |
| 144 scoped_refptr<SolidColorLayer> green = | 143 scoped_refptr<SolidColorLayer> green = |
| 145 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 144 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
| 146 background->AddChild(green); | 145 background->AddChild(green); |
| 147 | 146 |
| 148 RunReadbackTest(GetParam().pixel_test_type, GetParam().readback_type, | 147 RunReadbackTest(GetParam().pixel_test_type, GetParam().readback_type, |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 READBACK_DEFAULT), | 547 READBACK_DEFAULT), |
| 549 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, | 548 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, |
| 550 READBACK_DEFAULT), | 549 READBACK_DEFAULT), |
| 551 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, | 550 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, |
| 552 READBACK_BITMAP))); | 551 READBACK_BITMAP))); |
| 553 | 552 |
| 554 } // namespace | 553 } // namespace |
| 555 } // namespace cc | 554 } // namespace cc |
| 556 | 555 |
| 557 #endif // OS_ANDROID | 556 #endif // OS_ANDROID |
| OLD | NEW |