Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/tiles/image_controller.h" | 5 #include "cc/tiles/image_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/task_scheduler/post_task.h" | 8 #include "base/task_scheduler/post_task.h" |
| 9 #include "base/task_scheduler/task_traits.h" | 9 #include "base/task_scheduler/task_traits.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "cc/base/completion_event.h" | 12 #include "cc/base/completion_event.h" |
| 13 #include "cc/tiles/tile_task_manager.h" | 13 #include "cc/tiles/tile_task_manager.h" |
| 14 | 14 |
| 15 namespace cc { | 15 namespace cc { |
| 16 | 16 |
| 17 ImageController::ImageDecodeRequestId | 17 ImageController::ImageDecodeRequestId |
| 18 ImageController::s_next_image_decode_queue_id_ = 1; | 18 ImageController::s_next_image_decode_queue_id_ = 1; |
| 19 | 19 |
| 20 ImageController::ImageController( | 20 ImageController::ImageController( |
| 21 base::SequencedTaskRunner* origin_task_runner, | 21 base::SequencedTaskRunner* origin_task_runner, |
| 22 scoped_refptr<base::SequencedTaskRunner> worker_task_runner) | 22 scoped_refptr<base::SequencedTaskRunner> worker_task_runner) |
| 23 : worker_task_runner_(std::move(worker_task_runner)), | 23 : worker_task_runner_(std::move(worker_task_runner)), |
| 24 origin_task_runner_(origin_task_runner), | 24 origin_task_runner_(origin_task_runner), |
| 25 paint_image_id_(PaintImage::GetNextId()), | |
|
vmpstr
2017/05/12 22:15:42
This is something that we need to talk about I thi
Khushal
2017/05/13 02:45:50
We'll definitely need PaintImage plumbed to cc, in
vmpstr
2017/05/15 15:02:55
My concern is that it doesn't feel that we're clea
Khushal
2017/05/15 21:22:14
ImageHijackCanvas is one use-case. The other one i
| |
| 25 weak_ptr_factory_(this) {} | 26 weak_ptr_factory_(this) {} |
| 26 | 27 |
| 27 ImageController::~ImageController() { | 28 ImageController::~ImageController() { |
| 28 StopWorkerTasks(); | 29 StopWorkerTasks(); |
| 29 for (auto& request : orphaned_decode_requests_) | 30 for (auto& request : orphaned_decode_requests_) |
| 30 request.callback.Run(request.id, ImageDecodeResult::FAILURE); | 31 request.callback.Run(request.id, ImageDecodeResult::FAILURE); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void ImageController::StopWorkerTasks() { | 34 void ImageController::StopWorkerTasks() { |
| 34 // We can't have worker threads without a cache_ or a worker_task_runner_, so | 35 // We can't have worker threads without a cache_ or a worker_task_runner_, so |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 | 189 |
| 189 // TODO(ccameron): The target color space specified here should match the | 190 // TODO(ccameron): The target color space specified here should match the |
| 190 // target color space that will be used at rasterization time. Leave this | 191 // target color space that will be used at rasterization time. Leave this |
| 191 // unspecified now, since that will match the rasterization-time color | 192 // unspecified now, since that will match the rasterization-time color |
| 192 // space while color correct rendering is disabled. | 193 // space while color correct rendering is disabled. |
| 193 gfx::ColorSpace target_color_space; | 194 gfx::ColorSpace target_color_space; |
| 194 | 195 |
| 195 DCHECK(image); | 196 DCHECK(image); |
| 196 bool is_image_lazy = image->isLazyGenerated(); | 197 bool is_image_lazy = image->isLazyGenerated(); |
| 197 auto image_bounds = image->bounds(); | 198 auto image_bounds = image->bounds(); |
| 198 DrawImage draw_image(std::move(image), image_bounds, kNone_SkFilterQuality, | 199 DrawImage draw_image( |
| 199 SkMatrix::I(), target_color_space); | 200 PaintImage(paint_image_id_, |
| 201 sk_ref_sp(const_cast<SkImage*>(image.release()))), | |
| 202 image_bounds, kNone_SkFilterQuality, SkMatrix::I(), target_color_space); | |
| 200 | 203 |
| 201 // Get the tasks for this decode. | 204 // Get the tasks for this decode. |
| 202 scoped_refptr<TileTask> task; | 205 scoped_refptr<TileTask> task; |
| 203 bool need_unref = false; | 206 bool need_unref = false; |
| 204 if (is_image_lazy) { | 207 if (is_image_lazy) { |
| 205 need_unref = | 208 need_unref = |
| 206 cache_->GetOutOfRasterDecodeTaskForImageAndRef(draw_image, &task); | 209 cache_->GetOutOfRasterDecodeTaskForImageAndRef(draw_image, &task); |
| 207 } | 210 } |
| 208 // If we don't need to unref this, we don't actually have a task. | 211 // If we don't need to unref this, we don't actually have a task. |
| 209 DCHECK(need_unref || !task); | 212 DCHECK(need_unref || !task); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 ImageController::ImageDecodeRequest::ImageDecodeRequest( | 377 ImageController::ImageDecodeRequest::ImageDecodeRequest( |
| 375 const ImageDecodeRequest& other) = default; | 378 const ImageDecodeRequest& other) = default; |
| 376 ImageController::ImageDecodeRequest::~ImageDecodeRequest() = default; | 379 ImageController::ImageDecodeRequest::~ImageDecodeRequest() = default; |
| 377 | 380 |
| 378 ImageController::ImageDecodeRequest& ImageController::ImageDecodeRequest:: | 381 ImageController::ImageDecodeRequest& ImageController::ImageDecodeRequest:: |
| 379 operator=(ImageDecodeRequest&& other) = default; | 382 operator=(ImageDecodeRequest&& other) = default; |
| 380 ImageController::ImageDecodeRequest& ImageController::ImageDecodeRequest:: | 383 ImageController::ImageDecodeRequest& ImageController::ImageDecodeRequest:: |
| 381 operator=(const ImageDecodeRequest& other) = default; | 384 operator=(const ImageDecodeRequest& other) = default; |
| 382 | 385 |
| 383 } // namespace cc | 386 } // namespace cc |
| OLD | NEW |