| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/raster/gpu_raster_buffer_provider.h" | 5 #include "cc/raster/gpu_raster_buffer_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 static void RasterizePicture(SkPicture* picture, | 82 static void RasterizePicture(SkPicture* picture, |
| 83 ContextProvider* context_provider, | 83 ContextProvider* context_provider, |
| 84 ResourceProvider::ScopedWriteLockGL* resource_lock, | 84 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 85 bool async_worker_context_enabled, | 85 bool async_worker_context_enabled, |
| 86 bool use_distance_field_text, | 86 bool use_distance_field_text, |
| 87 bool can_use_lcd_text, | 87 bool can_use_lcd_text, |
| 88 bool ignore_resource_color_space, | 88 bool ignore_resource_color_space, |
| 89 int msaa_sample_count, | 89 int msaa_sample_count, |
| 90 ImageDecodeController* image_decode_controller, | 90 ImageDecodeCache* image_decode_cache, |
| 91 bool use_image_hijack_canvas) { | 91 bool use_image_hijack_canvas) { |
| 92 ScopedGpuRaster gpu_raster(context_provider); | 92 ScopedGpuRaster gpu_raster(context_provider); |
| 93 | 93 |
| 94 ResourceProvider::ScopedSkSurfaceProvider scoped_surface( | 94 ResourceProvider::ScopedSkSurfaceProvider scoped_surface( |
| 95 context_provider, resource_lock, async_worker_context_enabled, | 95 context_provider, resource_lock, async_worker_context_enabled, |
| 96 use_distance_field_text, can_use_lcd_text, ignore_resource_color_space, | 96 use_distance_field_text, can_use_lcd_text, ignore_resource_color_space, |
| 97 msaa_sample_count); | 97 msaa_sample_count); |
| 98 SkSurface* sk_surface = scoped_surface.sk_surface(); | 98 SkSurface* sk_surface = scoped_surface.sk_surface(); |
| 99 // Allocating an SkSurface will fail after a lost context. Pretend we | 99 // Allocating an SkSurface will fail after a lost context. Pretend we |
| 100 // rasterized, as the contents of the resource don't matter anymore. | 100 // rasterized, as the contents of the resource don't matter anymore. |
| 101 if (!sk_surface) | 101 if (!sk_surface) |
| 102 return; | 102 return; |
| 103 | 103 |
| 104 // As we did not use the image hijack canvas during the initial playback to | 104 // As we did not use the image hijack canvas during the initial playback to |
| 105 // |picture| (see PlaybackToPicture), we must enable it here if requested. | 105 // |picture| (see PlaybackToPicture), we must enable it here if requested. |
| 106 SkCanvas* canvas = sk_surface->getCanvas(); | 106 SkCanvas* canvas = sk_surface->getCanvas(); |
| 107 std::unique_ptr<ImageHijackCanvas> hijack_canvas; | 107 std::unique_ptr<ImageHijackCanvas> hijack_canvas; |
| 108 if (use_image_hijack_canvas) { | 108 if (use_image_hijack_canvas) { |
| 109 DCHECK(image_decode_controller); | 109 DCHECK(image_decode_cache); |
| 110 const SkImageInfo& info = canvas->imageInfo(); | 110 const SkImageInfo& info = canvas->imageInfo(); |
| 111 hijack_canvas.reset(new ImageHijackCanvas(info.width(), info.height(), | 111 hijack_canvas.reset( |
| 112 image_decode_controller)); | 112 new ImageHijackCanvas(info.width(), info.height(), image_decode_cache)); |
| 113 SkIRect raster_bounds; | 113 SkIRect raster_bounds; |
| 114 canvas->getClipDeviceBounds(&raster_bounds); | 114 canvas->getClipDeviceBounds(&raster_bounds); |
| 115 hijack_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); | 115 hijack_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds)); |
| 116 hijack_canvas->setMatrix(canvas->getTotalMatrix()); | 116 hijack_canvas->setMatrix(canvas->getTotalMatrix()); |
| 117 hijack_canvas->addCanvas(canvas); | 117 hijack_canvas->addCanvas(canvas); |
| 118 | 118 |
| 119 // Replace canvas with our ImageHijackCanvas which is wrapping it. | 119 // Replace canvas with our ImageHijackCanvas which is wrapping it. |
| 120 canvas = hijack_canvas.get(); | 120 canvas = hijack_canvas.get(); |
| 121 } | 121 } |
| 122 | 122 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 267 |
| 268 // Turn on distance fields for layers that have ever animated. | 268 // Turn on distance fields for layers that have ever animated. |
| 269 bool use_distance_field_text = | 269 bool use_distance_field_text = |
| 270 use_distance_field_text_ || | 270 use_distance_field_text_ || |
| 271 raster_source->ShouldAttemptToUseDistanceFieldText(); | 271 raster_source->ShouldAttemptToUseDistanceFieldText(); |
| 272 | 272 |
| 273 RasterizePicture(picture.get(), worker_context_provider_, resource_lock, | 273 RasterizePicture(picture.get(), worker_context_provider_, resource_lock, |
| 274 async_worker_context_enabled_, use_distance_field_text, | 274 async_worker_context_enabled_, use_distance_field_text, |
| 275 raster_source->CanUseLCDText(), | 275 raster_source->CanUseLCDText(), |
| 276 raster_source->HasImpliedColorSpace(), msaa_sample_count_, | 276 raster_source->HasImpliedColorSpace(), msaa_sample_count_, |
| 277 raster_source->image_decode_controller(), | 277 raster_source->image_decode_cache(), |
| 278 playback_settings.use_image_hijack_canvas); | 278 playback_settings.use_image_hijack_canvas); |
| 279 | 279 |
| 280 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); | 280 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 281 | 281 |
| 282 // Barrier to sync worker context output to cc context. | 282 // Barrier to sync worker context output to cc context. |
| 283 gl->OrderingBarrierCHROMIUM(); | 283 gl->OrderingBarrierCHROMIUM(); |
| 284 | 284 |
| 285 // Generate sync token after the barrier for cross context synchronization. | 285 // Generate sync token after the barrier for cross context synchronization. |
| 286 gpu::SyncToken resource_sync_token; | 286 gpu::SyncToken resource_sync_token; |
| 287 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); | 287 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); |
| 288 resource_lock->set_sync_token(resource_sync_token); | 288 resource_lock->set_sync_token(resource_sync_token); |
| 289 resource_lock->set_synchronized(!async_worker_context_enabled_); | 289 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace cc | 292 } // namespace cc |
| OLD | NEW |