| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
| 8 #include "cc/layers/picture_layer.h" | 8 #include "cc/layers/picture_layer.h" |
| 9 #include "cc/output/copy_output_request.h" | 9 #include "cc/output/copy_output_request.h" |
| 10 #include "cc/playback/display_item_list.h" | 10 #include "cc/playback/display_item_list.h" |
| 11 #include "cc/playback/display_item_list_settings.h" | 11 #include "cc/playback/display_item_list_settings.h" |
| 12 #include "cc/playback/drawing_display_item.h" | 12 #include "cc/playback/drawing_display_item.h" |
| 13 #include "cc/test/layer_tree_pixel_test.h" | 13 #include "cc/test/layer_tree_pixel_test.h" |
| 14 #include "cc/test/test_compositor_frame_sink.h" | |
| 15 #include "gpu/command_buffer/client/gles2_interface.h" | |
| 16 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "third_party/skia/include/core/SkPictureRecorder.h" | 15 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 18 | 16 |
| 19 #if !defined(OS_ANDROID) | 17 #if !defined(OS_ANDROID) |
| 20 | 18 |
| 21 namespace cc { | 19 namespace cc { |
| 22 namespace { | 20 namespace { |
| 23 | 21 |
| 24 enum RasterMode { | 22 enum RasterMode { |
| 25 PARTIAL_ONE_COPY, | 23 PARTIAL_ONE_COPY, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 LayerTreeHostTilesTestPartialInvalidation() | 153 LayerTreeHostTilesTestPartialInvalidation() |
| 156 : client_(gfx::Size(200, 200)), | 154 : client_(gfx::Size(200, 200)), |
| 157 picture_layer_(PictureLayer::Create(&client_)) { | 155 picture_layer_(PictureLayer::Create(&client_)) { |
| 158 picture_layer_->SetBounds(gfx::Size(200, 200)); | 156 picture_layer_->SetBounds(gfx::Size(200, 200)); |
| 159 picture_layer_->SetIsDrawable(true); | 157 picture_layer_->SetIsDrawable(true); |
| 160 } | 158 } |
| 161 | 159 |
| 162 void DidCommitAndDrawFrame() override { | 160 void DidCommitAndDrawFrame() override { |
| 163 switch (layer_tree_host()->SourceFrameNumber()) { | 161 switch (layer_tree_host()->SourceFrameNumber()) { |
| 164 case 1: | 162 case 1: |
| 165 // We have done one frame, but the resource may not be available for | 163 // We have done one frame, so the layer's content has been rastered. |
| 166 // partial raster yet. Force a second frame. | 164 // Now we change the picture behind it to record something completely |
| 167 picture_layer_->SetNeedsDisplayRect(gfx::Rect(50, 50, 100, 100)); | 165 // different, but we give a smaller invalidation rect. The layer should |
| 168 break; | 166 // only re-raster the stuff in the rect. If it doesn't do partial raster |
| 169 case 2: | 167 // it would re-raster the whole thing instead. |
| 170 // We have done two frames, so the layer's content has been rastered | |
| 171 // twice and the first frame's resource is available for partial | |
| 172 // raster. Now we change the picture behind it to record something | |
| 173 // completely different, but we give a smaller invalidation rect. The | |
| 174 // layer should only re-raster the stuff in the rect. If it doesn't do | |
| 175 // partial raster it would re-raster the whole thing instead. | |
| 176 client_.set_blue_top(false); | 168 client_.set_blue_top(false); |
| 177 Finish(); | 169 Finish(); |
| 178 picture_layer_->SetNeedsDisplayRect(gfx::Rect(50, 50, 100, 100)); | 170 picture_layer_->SetNeedsDisplayRect(gfx::Rect(50, 50, 100, 100)); |
| 179 | 171 |
| 180 // Add a copy request to see what happened! | 172 // Add a copy request to see what happened! |
| 181 DoReadback(); | 173 DoReadback(); |
| 182 break; | 174 break; |
| 183 } | 175 } |
| 184 } | 176 } |
| 185 | 177 |
| 186 void WillPrepareTilesOnThread(LayerTreeHostImpl* host_impl) override { | |
| 187 // Issue a GL finish before preparing tiles to ensure resources become | |
| 188 // available for use in a timely manner. Needed for the one-copy path. | |
| 189 ContextProvider* context_provider = | |
| 190 host_impl->compositor_frame_sink()->worker_context_provider(); | |
| 191 if (!context_provider) | |
| 192 return; | |
| 193 | |
| 194 ContextProvider::ScopedContextLock lock(context_provider); | |
| 195 lock.ContextGL()->Finish(); | |
| 196 } | |
| 197 | |
| 198 protected: | 178 protected: |
| 199 BlueYellowClient client_; | 179 BlueYellowClient client_; |
| 200 scoped_refptr<PictureLayer> picture_layer_; | 180 scoped_refptr<PictureLayer> picture_layer_; |
| 201 }; | 181 }; |
| 202 | 182 |
| 203 TEST_F(LayerTreeHostTilesTestPartialInvalidation, | 183 TEST_F(LayerTreeHostTilesTestPartialInvalidation, |
| 204 PartialRaster_SingleThread_OneCopy) { | 184 PartialRaster_SingleThread_OneCopy) { |
| 205 RunRasterPixelTest( | 185 RunRasterPixelTest( |
| 206 false, PARTIAL_ONE_COPY, picture_layer_, | 186 false, PARTIAL_ONE_COPY, picture_layer_, |
| 207 base::FilePath(FILE_PATH_LITERAL("blue_yellow_partial_flipped.png"))); | 187 base::FilePath(FILE_PATH_LITERAL("blue_yellow_partial_flipped.png"))); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 FullRaster_SingleThread_GpuRaster) { | 233 FullRaster_SingleThread_GpuRaster) { |
| 254 RunRasterPixelTest( | 234 RunRasterPixelTest( |
| 255 false, FULL_GPU, picture_layer_, | 235 false, FULL_GPU, picture_layer_, |
| 256 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); | 236 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); |
| 257 } | 237 } |
| 258 | 238 |
| 259 } // namespace | 239 } // namespace |
| 260 } // namespace cc | 240 } // namespace cc |
| 261 | 241 |
| 262 #endif // !defined(OS_ANDROID) | 242 #endif // !defined(OS_ANDROID) |
| OLD | NEW |