| 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/resources/gpu_raster_worker_pool.h" | 5 #include "cc/resources/gpu_raster_worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 SkMultiPictureDraw* multi_picture_draw) | 29 SkMultiPictureDraw* multi_picture_draw) |
| 30 : resource_provider_(resource_provider), | 30 : resource_provider_(resource_provider), |
| 31 resource_(resource), | 31 resource_(resource), |
| 32 surface_(resource_provider->LockForWriteToSkSurface(resource->id())), | 32 surface_(resource_provider->LockForWriteToSkSurface(resource->id())), |
| 33 multi_picture_draw_(multi_picture_draw) {} | 33 multi_picture_draw_(multi_picture_draw) {} |
| 34 virtual ~RasterBufferImpl() { | 34 virtual ~RasterBufferImpl() { |
| 35 resource_provider_->UnlockForWriteToSkSurface(resource_->id()); | 35 resource_provider_->UnlockForWriteToSkSurface(resource_->id()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Overridden from RasterBuffer: | 38 // Overridden from RasterBuffer: |
| 39 virtual skia::RefPtr<SkCanvas> AcquireSkCanvas() OVERRIDE { | 39 virtual skia::RefPtr<SkCanvas> AcquireSkCanvas() override { |
| 40 if (!surface_) | 40 if (!surface_) |
| 41 return skia::AdoptRef(SkCreateNullCanvas()); | 41 return skia::AdoptRef(SkCreateNullCanvas()); |
| 42 | 42 |
| 43 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(recorder_.beginRecording( | 43 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(recorder_.beginRecording( |
| 44 resource_->size().width(), resource_->size().height())); | 44 resource_->size().width(), resource_->size().height())); |
| 45 | 45 |
| 46 // Balanced with restore() call in ReleaseSkCanvas. save()/restore() calls | 46 // Balanced with restore() call in ReleaseSkCanvas. save()/restore() calls |
| 47 // are needed to ensure that canvas returns to its previous state after use. | 47 // are needed to ensure that canvas returns to its previous state after use. |
| 48 canvas->save(); | 48 canvas->save(); |
| 49 return canvas; | 49 return canvas; |
| 50 } | 50 } |
| 51 virtual void ReleaseSkCanvas(const skia::RefPtr<SkCanvas>& canvas) OVERRIDE { | 51 virtual void ReleaseSkCanvas(const skia::RefPtr<SkCanvas>& canvas) override { |
| 52 if (!surface_) | 52 if (!surface_) |
| 53 return; | 53 return; |
| 54 | 54 |
| 55 // Balanced with save() call in AcquireSkCanvas. | 55 // Balanced with save() call in AcquireSkCanvas. |
| 56 canvas->restore(); | 56 canvas->restore(); |
| 57 | 57 |
| 58 // Add the canvas and recorded picture to |multi_picture_draw_|. | 58 // Add the canvas and recorded picture to |multi_picture_draw_|. |
| 59 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder_.endRecording()); | 59 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder_.endRecording()); |
| 60 multi_picture_draw_->add(surface_->getCanvas(), picture.get()); | 60 multi_picture_draw_->add(surface_->getCanvas(), picture.get()); |
| 61 } | 61 } |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 ScopedGpuRaster gpu_raster(context_provider_); | 240 ScopedGpuRaster gpu_raster(context_provider_); |
| 241 task_graph_runner_->RunUntilIdle(); | 241 task_graph_runner_->RunUntilIdle(); |
| 242 | 242 |
| 243 // Draw each all of the pictures that were collected. This will also clear | 243 // Draw each all of the pictures that were collected. This will also clear |
| 244 // the pictures and canvases added to |multi_picture_draw_| | 244 // the pictures and canvases added to |multi_picture_draw_| |
| 245 multi_picture_draw_.draw(); | 245 multi_picture_draw_.draw(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace cc | 248 } // namespace cc |
| OLD | NEW |