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

Unified Diff: ui/gl/gpu_timing.h

Issue 937263006: Refactored GLContext to own GPUTiming which spawn GPUTimingClients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged with latest Created 5 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
Index: ui/gl/gpu_timing.h
diff --git a/gpu/command_buffer/service/gpu_timing.h b/ui/gl/gpu_timing.h
similarity index 65%
rename from gpu/command_buffer/service/gpu_timing.h
rename to ui/gl/gpu_timing.h
index 726ac4e5f776a19a466276edd017a4a48cfc0446..cc56627cd808c631d3ddcffa3d70c30c1bdcc376 100644
--- a/gpu/command_buffer/service/gpu_timing.h
+++ b/ui/gl/gpu_timing.h
@@ -7,21 +7,43 @@
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
-#include "gpu/gpu_export.h"
+#include "ui/gl/gl_export.h"
namespace gfx {
class GLContext;
}
namespace gpu {
piman 2015/02/25 01:00:53 nit: probably should be namespace gfx for consiste
David Yen 2015/02/25 01:47:36 Done.
-class GPUTiming;
+
+class GPUTimingClient;
+
+class GL_EXPORT GPUTiming {
piman 2015/02/25 01:00:53 nit: it's not clear what is GPUTiming vs GPUTimer.
David Yen 2015/02/25 01:47:35 Let me discuss this with dcastagna since he was th
Daniele Castagna 2015/02/25 17:42:02 Do we still need to keep this class? Now that the
David Yen 2015/02/25 17:48:53 You are correct that currently it does almost noth
Daniele Castagna 2015/02/25 19:46:24 It could be nice to have a comment explaining what
David Yen 2015/02/25 23:02:31 I can't think of anything better either. I have ad
+ public:
+ enum TimerType {
+ kTimerTypeInvalid = -1,
+
+ kTimerTypeARB, // ARB_timer_query
+ kTimerTypeDisjoint // EXT_disjoint_timer_query
+ };
+
+ explicit GPUTiming(gfx::GLContext* context = nullptr);
+ virtual ~GPUTiming();
+
+ void Initialize(gfx::GLContext* context);
+
+ TimerType GetTimerType() const { return timer_type_; }
+
+ scoped_refptr<GPUTimingClient> CreateGPUTimingClient();
+
+ private:
+ TimerType timer_type_ = kTimerTypeInvalid;
+ DISALLOW_COPY_AND_ASSIGN(GPUTiming);
+};
// Class to compute the amount of time it takes to fully
// complete a set of GL commands
-class GPU_EXPORT GPUTimer {
+class GL_EXPORT GPUTimer {
public:
- // gpu_timing must outlive GPUTimer instance we're creating.
- explicit GPUTimer(GPUTiming* gpu_timing);
~GPUTimer();
void Start();
@@ -32,30 +54,28 @@ class GPU_EXPORT GPUTimer {
int64 GetDeltaElapsed();
private:
+ // gpu_timing_client must outlive GPUTimer instance we're creating.
piman 2015/02/25 01:00:53 Should you just take a reference then?
David Yen 2015/02/25 01:47:35 Possibly, although in practice I don't think that
Daniele Castagna 2015/02/25 17:42:02 I think a reference would be nicer but according t
David Yen 2015/02/25 17:48:53 I interpreted piman's comment as making this a sco
Daniele Castagna 2015/02/25 19:46:24 GPUTimingClient already extends base::RefCounted,
David Yen 2015/02/25 23:02:31 Done.
+ explicit GPUTimer(GPUTimingClient* gpu_timing_client);
+
unsigned int queries_[2];
int64 offset_ = 0;
bool end_requested_ = false;
- GPUTiming* gpu_timing_;
+ GPUTimingClient* gpu_timing_client_;
+ friend class GPUTimingClient;
piman 2015/02/25 01:00:53 nit: friend declaration should be first in the pri
David Yen 2015/02/25 01:47:35 Done.
DISALLOW_COPY_AND_ASSIGN(GPUTimer);
};
-// GPUTiming contains all the gl timing logic that is not specific
+// GPUTimingClient contains all the gl timing logic that is not specific
// to a single GPUTimer.
-class GPU_EXPORT GPUTiming {
+class GL_EXPORT GPUTimingClient
Ken Russell (switch to Gerrit) 2015/02/25 00:55:17 I thought the design was going to be more of this
David Yen 2015/02/25 01:47:35 Almost, as you said GPUTiming should be hidden ins
+ : public base::RefCounted<GPUTimingClient> {
public:
- enum TimerType {
- kTimerTypeInvalid = -1,
-
- kTimerTypeARB, // ARB_timer_query
- kTimerTypeDisjoint // EXT_disjoint_timer_query
- };
+ explicit GPUTimingClient(GPUTiming* gpu_timing = nullptr);
- GPUTiming();
- virtual ~GPUTiming();
-
- bool Initialize(gfx::GLContext* context);
+ scoped_ptr<GPUTimer> CreateGPUTimer();
bool IsAvailable();
+ const char* GetTimerTypeName() const;
// CheckAndResetTimerErrors has to be called before reading timestamps
// from GPUTimers instances and after making sure all the timers
@@ -64,24 +84,27 @@ class GPU_EXPORT GPUTiming {
// discarded.
bool CheckAndResetTimerErrors();
- const char* GetTimerTypeName() const;
-
// Returns the offset between the current gpu time and the cpu time.
int64 CalculateTimerOffset();
void InvalidateTimerOffset();
void SetCpuTimeForTesting(const base::Callback<int64(void)>& cpu_time);
- void SetOffsetForTesting(int64 offset, bool cache_it);
- void SetTimerTypeForTesting(TimerType type);
- private:
- TimerType timer_type_ = kTimerTypeInvalid;
+ protected:
+ virtual ~GPUTimingClient();
+
+ GPUTiming* gpu_timing_;
+ GPUTiming::TimerType timer_type_ = GPUTiming::kTimerTypeInvalid;
int64 offset_ = 0; // offset cache when timer_type_ == kTimerTypeARB
bool offset_valid_ = false;
base::Callback<int64(void)> cpu_time_for_testing_;
+
+ friend class base::RefCounted<GPUTimingClient>;
friend class GPUTimer;
- DISALLOW_COPY_AND_ASSIGN(GPUTiming);
+ friend class GPUTiming;
+ DISALLOW_COPY_AND_ASSIGN(GPUTimingClient);
};
+
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_TIMING_H_
« ui/gl/gl_context.cc ('K') | « ui/gl/gl_context.cc ('k') | ui/gl/gpu_timing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698