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

Unified Diff: gpu/command_buffer/service/gpu_scheduler.h

Issue 12226039: Reland 179911 and 179910 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src
Patch Set: Delta from original landing that's necessary for M25 (not ToT) Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/texture_image_transport_surface.cc ('k') | gpu/command_buffer/service/gpu_scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gpu_scheduler.h
diff --git a/gpu/command_buffer/service/gpu_scheduler.h b/gpu/command_buffer/service/gpu_scheduler.h
index 9aa7d9e9dfd028b744cce9991c303ff5fb2fe9f8..30aaf56268929939907d34a030f99350d8a4d18f 100644
--- a/gpu/command_buffer/service/gpu_scheduler.h
+++ b/gpu/command_buffer/service/gpu_scheduler.h
@@ -27,19 +27,21 @@ class GLFence;
namespace gpu {
-struct RefCountedCounter
- : public base::RefCountedThreadSafe<RefCountedCounter> {
- base::AtomicRefCount count;
- RefCountedCounter() : count(0) {}
-
- bool IsZero() { return base::AtomicRefCountIsZero(&count); }
- void IncCount() { base::AtomicRefCountInc(&count); }
- void DecCount() { base::AtomicRefCountDec(&count); }
- void Reset() { base::subtle::NoBarrier_Store(&count, 0); }
+class PreemptionFlag
+ : public base::RefCountedThreadSafe<PreemptionFlag> {
+ public:
+ PreemptionFlag() : flag_(0) {}
+
+ bool IsSet() { return base::AtomicRefCountIsZero(&flag_); }
+ void Set() { base::AtomicRefCountInc(&flag_); }
+ void Reset() { base::subtle::NoBarrier_Store(&flag_, 0); }
+
private:
- ~RefCountedCounter() {}
+ base::AtomicRefCount flag_;
- friend class base::RefCountedThreadSafe<RefCountedCounter>;
+ ~PreemptionFlag() {}
+
+ friend class base::RefCountedThreadSafe<PreemptionFlag>;
};
// This class schedules commands that have been flushed. They are received via
@@ -58,8 +60,8 @@ class GPU_EXPORT GpuScheduler
void PutChanged();
- void SetPreemptByCounter(scoped_refptr<RefCountedCounter> counter) {
- preempt_by_counter_ = counter;
+ void SetPreemptByFlag(scoped_refptr<PreemptionFlag> flag) {
+ preemption_flag_ = flag;
}
// Sets whether commands should be processed by this scheduler. Setting to
@@ -97,6 +99,8 @@ class GPU_EXPORT GpuScheduler
return parser_.get();
}
+ bool IsPreempted();
+
private:
// Artificially reschedule if the scheduler is still unscheduled after a
// timeout.
@@ -145,9 +149,8 @@ class GPU_EXPORT GpuScheduler
base::Closure scheduled_callback_;
base::Closure command_processed_callback_;
- // If non-NULL and preempt_by_counter_->count is non-zero,
- // exit PutChanged early.
- scoped_refptr<RefCountedCounter> preempt_by_counter_;
+ // If non-NULL and |preemption_flag_->IsSet()|, exit PutChanged early.
+ scoped_refptr<PreemptionFlag> preemption_flag_;
bool was_preempted_;
DISALLOW_COPY_AND_ASSIGN(GpuScheduler);
« no previous file with comments | « content/common/gpu/texture_image_transport_surface.cc ('k') | gpu/command_buffer/service/gpu_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698