| 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" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "third_party/skia/include/core/SkPictureRecorder.h" | 17 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 16 | 18 |
| 17 #if !defined(OS_ANDROID) | 19 #if !defined(OS_ANDROID) |
| 18 | 20 |
| 19 namespace cc { | 21 namespace cc { |
| 20 namespace { | 22 namespace { |
| 21 | 23 |
| 22 enum RasterMode { | 24 enum RasterMode { |
| 23 PARTIAL_ONE_COPY, | 25 PARTIAL_ONE_COPY, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 LayerTreeHostTilesTestPartialInvalidation() | 155 LayerTreeHostTilesTestPartialInvalidation() |
| 154 : client_(gfx::Size(200, 200)), | 156 : client_(gfx::Size(200, 200)), |
| 155 picture_layer_(PictureLayer::Create(&client_)) { | 157 picture_layer_(PictureLayer::Create(&client_)) { |
| 156 picture_layer_->SetBounds(gfx::Size(200, 200)); | 158 picture_layer_->SetBounds(gfx::Size(200, 200)); |
| 157 picture_layer_->SetIsDrawable(true); | 159 picture_layer_->SetIsDrawable(true); |
| 158 } | 160 } |
| 159 | 161 |
| 160 void DidCommitAndDrawFrame() override { | 162 void DidCommitAndDrawFrame() override { |
| 161 switch (layer_tree_host()->SourceFrameNumber()) { | 163 switch (layer_tree_host()->SourceFrameNumber()) { |
| 162 case 1: | 164 case 1: |
| 163 // We have done one frame, so the layer's content has been rastered. | 165 // We have done one frame, but the resource may not be available for |
| 164 // Now we change the picture behind it to record something completely | 166 // partial raster yet. Force a second frame. |
| 165 // different, but we give a smaller invalidation rect. The layer should | 167 picture_layer_->SetNeedsDisplayRect(gfx::Rect(50, 50, 100, 100)); |
| 166 // only re-raster the stuff in the rect. If it doesn't do partial raster | 168 break; |
| 167 // it would re-raster the whole thing instead. | 169 case 2: |
| 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. |
| 168 client_.set_blue_top(false); | 176 client_.set_blue_top(false); |
| 169 Finish(); | 177 Finish(); |
| 170 picture_layer_->SetNeedsDisplayRect(gfx::Rect(50, 50, 100, 100)); | 178 picture_layer_->SetNeedsDisplayRect(gfx::Rect(50, 50, 100, 100)); |
| 171 | 179 |
| 172 // Add a copy request to see what happened! | 180 // Add a copy request to see what happened! |
| 173 DoReadback(); | 181 DoReadback(); |
| 174 break; | 182 break; |
| 175 } | 183 } |
| 176 } | 184 } |
| 177 | 185 |
| 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 |
| 178 protected: | 198 protected: |
| 179 BlueYellowClient client_; | 199 BlueYellowClient client_; |
| 180 scoped_refptr<PictureLayer> picture_layer_; | 200 scoped_refptr<PictureLayer> picture_layer_; |
| 181 }; | 201 }; |
| 182 | 202 |
| 183 TEST_F(LayerTreeHostTilesTestPartialInvalidation, | 203 TEST_F(LayerTreeHostTilesTestPartialInvalidation, |
| 184 PartialRaster_SingleThread_OneCopy) { | 204 PartialRaster_SingleThread_OneCopy) { |
| 185 RunRasterPixelTest( | 205 RunRasterPixelTest( |
| 186 false, PARTIAL_ONE_COPY, picture_layer_, | 206 false, PARTIAL_ONE_COPY, picture_layer_, |
| 187 base::FilePath(FILE_PATH_LITERAL("blue_yellow_partial_flipped.png"))); | 207 base::FilePath(FILE_PATH_LITERAL("blue_yellow_partial_flipped.png"))); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 FullRaster_SingleThread_GpuRaster) { | 253 FullRaster_SingleThread_GpuRaster) { |
| 234 RunRasterPixelTest( | 254 RunRasterPixelTest( |
| 235 false, FULL_GPU, picture_layer_, | 255 false, FULL_GPU, picture_layer_, |
| 236 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); | 256 base::FilePath(FILE_PATH_LITERAL("blue_yellow_flipped.png"))); |
| 237 } | 257 } |
| 238 | 258 |
| 239 } // namespace | 259 } // namespace |
| 240 } // namespace cc | 260 } // namespace cc |
| 241 | 261 |
| 242 #endif // !defined(OS_ANDROID) | 262 #endif // !defined(OS_ANDROID) |
| OLD | NEW |