Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: cc/tiles/gpu_image_decode_controller.cc

Issue 1866043006: cc: Remove ScheduleOnOriginThread() and CompleteOnOriginThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/gpu_image_decode_controller.h" 5 #include "cc/tiles/gpu_image_decode_controller.h"
6 6
7 #include "base/memory/discardable_memory_allocator.h" 7 #include "base/memory/discardable_memory_allocator.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/numerics/safe_math.h" 9 #include "base/numerics/safe_math.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 // Overridden from Task: 71 // Overridden from Task:
72 void RunOnWorkerThread() override { 72 void RunOnWorkerThread() override {
73 TRACE_EVENT2("cc", "ImageDecodeTaskImpl::RunOnWorkerThread", "mode", "gpu", 73 TRACE_EVENT2("cc", "ImageDecodeTaskImpl::RunOnWorkerThread", "mode", "gpu",
74 "source_prepare_tiles_id", tracing_info_.prepare_tiles_id); 74 "source_prepare_tiles_id", tracing_info_.prepare_tiles_id);
75 controller_->DecodeImage(image_); 75 controller_->DecodeImage(image_);
76 } 76 }
77 77
78 // Overridden from TileTask: 78 // Overridden from TileTask:
79 void ScheduleOnOriginThread(RasterBufferProvider* provider) override {} 79 void OnTaskCompleted() override {
80 void CompleteOnOriginThread(RasterBufferProvider* provider) override { 80 controller_->OnImageDecodeTaskCompleted(image_);
81 controller_->DecodeTaskCompleted(image_);
82 } 81 }
83 82
84 protected: 83 protected:
85 ~ImageDecodeTaskImpl() override {} 84 ~ImageDecodeTaskImpl() override {}
86 85
87 private: 86 private:
88 GpuImageDecodeController* controller_; 87 GpuImageDecodeController* controller_;
89 DrawImage image_; 88 DrawImage image_;
90 const ImageDecodeController::TracingInfo tracing_info_; 89 const ImageDecodeController::TracingInfo tracing_info_;
91 90
(...skipping 20 matching lines...) Expand all
112 dependencies_.push_back(std::move(decode_dependency)); 111 dependencies_.push_back(std::move(decode_dependency));
113 } 112 }
114 113
115 // Override from Task: 114 // Override from Task:
116 void RunOnWorkerThread() override { 115 void RunOnWorkerThread() override {
117 TRACE_EVENT2("cc", "ImageUploadTaskImpl::RunOnWorkerThread", "mode", "gpu", 116 TRACE_EVENT2("cc", "ImageUploadTaskImpl::RunOnWorkerThread", "mode", "gpu",
118 "source_prepare_tiles_id", tracing_info_.prepare_tiles_id); 117 "source_prepare_tiles_id", tracing_info_.prepare_tiles_id);
119 controller_->UploadImage(image_); 118 controller_->UploadImage(image_);
120 } 119 }
121 120
122 void ScheduleOnOriginThread(RasterBufferProvider* provider) override {} 121 // Overridden from TileTask:
123 void CompleteOnOriginThread(RasterBufferProvider* provider) override { 122 void OnTaskCompleted() override {
124 controller_->UploadTaskCompleted(image_); 123 controller_->OnImageUploadTaskCompleted(image_);
125 } 124 }
126 125
127 protected: 126 protected:
128 ~ImageUploadTaskImpl() override {} 127 ~ImageUploadTaskImpl() override {}
129 128
130 private: 129 private:
131 GpuImageDecodeController* controller_; 130 GpuImageDecodeController* controller_;
132 DrawImage image_; 131 DrawImage image_;
133 const ImageDecodeController::TracingInfo tracing_info_; 132 const ImageDecodeController::TracingInfo tracing_info_;
134 133
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 435
437 void GpuImageDecodeController::UploadImage(const DrawImage& draw_image) { 436 void GpuImageDecodeController::UploadImage(const DrawImage& draw_image) {
438 ContextProvider::ScopedContextLock context_lock(context_); 437 ContextProvider::ScopedContextLock context_lock(context_);
439 base::AutoLock lock(lock_); 438 base::AutoLock lock(lock_);
440 auto found = image_data_.Peek(draw_image.image()->uniqueID()); 439 auto found = image_data_.Peek(draw_image.image()->uniqueID());
441 DCHECK(found != image_data_.end()); 440 DCHECK(found != image_data_.end());
442 DCHECK(!found->second->is_at_raster); 441 DCHECK(!found->second->is_at_raster);
443 UploadImageIfNecessary(draw_image, found->second.get()); 442 UploadImageIfNecessary(draw_image, found->second.get());
444 } 443 }
445 444
446 void GpuImageDecodeController::DecodeTaskCompleted( 445 void GpuImageDecodeController::OnImageDecodeTaskCompleted(
447 const DrawImage& draw_image) { 446 const DrawImage& draw_image) {
448 base::AutoLock lock(lock_); 447 base::AutoLock lock(lock_);
449 // Decode task is complete, remove it from our list of pending tasks. 448 // Decode task is complete, remove it from our list of pending tasks.
450 pending_image_decode_tasks_.erase(draw_image.image()->uniqueID()); 449 pending_image_decode_tasks_.erase(draw_image.image()->uniqueID());
451 450
452 // While the decode task is active, we keep a ref on the decoded data. 451 // While the decode task is active, we keep a ref on the decoded data.
453 // Release that ref now. 452 // Release that ref now.
454 UnrefImageDecode(draw_image); 453 UnrefImageDecode(draw_image);
455 } 454 }
456 455
457 void GpuImageDecodeController::UploadTaskCompleted( 456 void GpuImageDecodeController::OnImageUploadTaskCompleted(
458 const DrawImage& draw_image) { 457 const DrawImage& draw_image) {
459 base::AutoLock lock(lock_); 458 base::AutoLock lock(lock_);
460 // Upload task is complete, remove it from our list of pending tasks. 459 // Upload task is complete, remove it from our list of pending tasks.
461 pending_image_upload_tasks_.erase(draw_image.image()->uniqueID()); 460 pending_image_upload_tasks_.erase(draw_image.image()->uniqueID());
462 461
463 // While the upload task is active, we keep a ref on both the image it will be 462 // While the upload task is active, we keep a ref on both the image it will be
464 // populating, as well as the decode it needs to populate it. Release these 463 // populating, as well as the decode it needs to populate it. Release these
465 // refs now. 464 // refs now.
466 UnrefImageDecode(draw_image); 465 UnrefImageDecode(draw_image);
467 UnrefImageInternal(draw_image); 466 UnrefImageInternal(draw_image);
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 bool GpuImageDecodeController::DiscardableIsLockedForTesting( 857 bool GpuImageDecodeController::DiscardableIsLockedForTesting(
859 const DrawImage& image) { 858 const DrawImage& image) {
860 base::AutoLock lock(lock_); 859 base::AutoLock lock(lock_);
861 auto found = image_data_.Peek(image.image()->uniqueID()); 860 auto found = image_data_.Peek(image.image()->uniqueID());
862 DCHECK(found != image_data_.end()); 861 DCHECK(found != image_data_.end());
863 ImageData* image_data = found->second.get(); 862 ImageData* image_data = found->second.get();
864 return image_data->decode.is_locked; 863 return image_data->decode.is_locked;
865 } 864 }
866 865
867 } // namespace cc 866 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/gpu_image_decode_controller.h ('k') | cc/tiles/gpu_image_decode_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698