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

Side by Side Diff: cc/tiles/software_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, 8 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 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 "cc/tiles/software_image_decode_controller.h" 5 #include "cc/tiles/software_image_decode_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <functional> 9 #include <functional>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 class ImageDecodeTaskImpl : public ImageDecodeTask { 57 class ImageDecodeTaskImpl : public ImageDecodeTask {
58 public: 58 public:
59 ImageDecodeTaskImpl(SoftwareImageDecodeController* controller, 59 ImageDecodeTaskImpl(SoftwareImageDecodeController* controller,
60 const SoftwareImageDecodeController::ImageKey& image_key, 60 const SoftwareImageDecodeController::ImageKey& image_key,
61 const DrawImage& image, 61 const DrawImage& image,
62 uint64_t source_prepare_tiles_id) 62 uint64_t source_prepare_tiles_id)
63 : controller_(controller), 63 : controller_(controller),
64 image_key_(image_key), 64 image_key_(image_key),
65 image_(image), 65 image_(image),
66 image_ref_(skia::SharePtr(image.image())), 66 image_ref_(skia::SharePtr(image.image())),
67 source_prepare_tiles_id_(source_prepare_tiles_id) {} 67 source_prepare_tiles_id_(source_prepare_tiles_id) {
68 SetTaskTypeId(TASK_TYPE_IMAGE_DECODE);
69 }
68 70
69 // Overridden from Task: 71 // Overridden from Task:
70 void RunOnWorkerThread() override { 72 void RunOnWorkerThread() override {
71 TRACE_EVENT2("cc", "ImageDecodeTaskImpl::RunOnWorkerThread", "mode", 73 TRACE_EVENT2("cc", "ImageDecodeTaskImpl::RunOnWorkerThread", "mode",
72 "software", "source_prepare_tiles_id", 74 "software", "source_prepare_tiles_id",
73 source_prepare_tiles_id_); 75 source_prepare_tiles_id_);
74 devtools_instrumentation::ScopedImageDecodeTask image_decode_task( 76 devtools_instrumentation::ScopedImageDecodeTask image_decode_task(
75 image_ref_.get()); 77 image_ref_.get());
76 controller_->DecodeImage(image_key_, image_); 78 controller_->DecodeImage(image_key_, image_);
77 } 79 }
78 80
79 // Overridden from TileTask:
80 void ScheduleOnOriginThread(TileTaskClient* client) override {}
81 void CompleteOnOriginThread(TileTaskClient* client) override {
82 controller_->RemovePendingTask(image_key_);
83 }
84
85 protected: 81 protected:
86 ~ImageDecodeTaskImpl() override {} 82 ~ImageDecodeTaskImpl() override {}
87 83
88 private: 84 public:
89 SoftwareImageDecodeController* controller_; 85 SoftwareImageDecodeController* controller_;
90 SoftwareImageDecodeController::ImageKey image_key_; 86 SoftwareImageDecodeController::ImageKey image_key_;
91 DrawImage image_; 87 DrawImage image_;
92 skia::RefPtr<const SkImage> image_ref_; 88 skia::RefPtr<const SkImage> image_ref_;
93 uint64_t source_prepare_tiles_id_; 89 uint64_t source_prepare_tiles_id_;
94 90
91 private:
95 DISALLOW_COPY_AND_ASSIGN(ImageDecodeTaskImpl); 92 DISALLOW_COPY_AND_ASSIGN(ImageDecodeTaskImpl);
96 }; 93 };
97 94
98 SkSize GetScaleAdjustment(const ImageDecodeControllerKey& key) { 95 SkSize GetScaleAdjustment(const ImageDecodeControllerKey& key) {
99 // If the requested filter quality did not require scale, then the adjustment 96 // If the requested filter quality did not require scale, then the adjustment
100 // is identity. 97 // is identity.
101 if (key.can_use_original_decode()) 98 if (key.can_use_original_decode())
102 return SkSize::Make(1.f, 1.f); 99 return SkSize::Make(1.f, 1.f);
103 100
104 float x_scale = 101 float x_scale =
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 if (it->second->is_locked()) { 678 if (it->second->is_locked()) {
682 ++it; 679 ++it;
683 continue; 680 continue;
684 } 681 }
685 682
686 it = decoded_images_.Erase(it); 683 it = decoded_images_.Erase(it);
687 --num_to_remove; 684 --num_to_remove;
688 } 685 }
689 } 686 }
690 687
688 void SoftwareImageDecodeController::ImageDecodeTaskCompleted(Task* task) {
689 ImageDecodeTaskImpl* decode_task = static_cast<ImageDecodeTaskImpl*>(task);
690 DCHECK(decode_task);
691 RemovePendingTask(decode_task->image_key_);
692 }
693
691 void SoftwareImageDecodeController::RemovePendingTask(const ImageKey& key) { 694 void SoftwareImageDecodeController::RemovePendingTask(const ImageKey& key) {
692 base::AutoLock lock(lock_); 695 base::AutoLock lock(lock_);
693 pending_image_tasks_.erase(key); 696 pending_image_tasks_.erase(key);
694 } 697 }
695 698
696 bool SoftwareImageDecodeController::OnMemoryDump( 699 bool SoftwareImageDecodeController::OnMemoryDump(
697 const base::trace_event::MemoryDumpArgs& args, 700 const base::trace_event::MemoryDumpArgs& args,
698 base::trace_event::ProcessMemoryDump* pmd) { 701 base::trace_event::ProcessMemoryDump* pmd) {
699 base::AutoLock lock(lock_); 702 base::AutoLock lock(lock_);
700 703
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { 929 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() {
927 current_usage_bytes_ = 0; 930 current_usage_bytes_ = 0;
928 } 931 }
929 932
930 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() 933 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe()
931 const { 934 const {
932 return current_usage_bytes_.ValueOrDie(); 935 return current_usage_bytes_.ValueOrDie();
933 } 936 }
934 937
935 } // namespace cc 938 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698