summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorboliu <boliu@chromium.org>2015-02-04 12:47:11 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-04 20:47:55 +0000
commit574dc108b871f8be73c882a52fa9a8623d3c7537 (patch)
tree416c370b6da290f1467e05194bc0a0eddca9a179 /ui
parent7a2217569bc1a7596ad6671513249e241b3491c3 (diff)
downloadchromium_src-574dc108b871f8be73c882a52fa9a8623d3c7537.zip
chromium_src-574dc108b871f8be73c882a52fa9a8623d3c7537.tar.gz
chromium_src-574dc108b871f8be73c882a52fa9a8623d3c7537.tar.bz2
Remove GLFence::CreateWithoutFlush
There is no callers for this anymore. Remove it and all the unnecessary code. BUG= Review URL: https://codereview.chromium.org/898543002 Cr-Commit-Position: refs/heads/master@{#314627}
Diffstat (limited to 'ui')
-rw-r--r--ui/gl/gl_context.cc27
-rw-r--r--ui/gl/gl_context.h24
-rw-r--r--ui/gl/gl_fence.cc53
-rw-r--r--ui/gl/gl_fence.h6
-rw-r--r--ui/gl/gl_fence_apple.cc15
-rw-r--r--ui/gl/gl_fence_apple.h4
-rw-r--r--ui/gl/gl_fence_arb.cc29
-rw-r--r--ui/gl/gl_fence_arb.h4
-rw-r--r--ui/gl/gl_fence_egl.cc39
-rw-r--r--ui/gl/gl_fence_egl.h4
-rw-r--r--ui/gl/gl_fence_nv.cc15
-rw-r--r--ui/gl/gl_fence_nv.h4
-rw-r--r--ui/gl/gl_gl_api_implementation.cc9
-rw-r--r--ui/gl/gl_gl_api_implementation.h1
14 files changed, 51 insertions, 183 deletions
diff --git a/ui/gl/gl_context.cc b/ui/gl/gl_context.cc
index 4cfcf73..f89f1d2 100644
--- a/ui/gl/gl_context.cc
+++ b/ui/gl/gl_context.cc
@@ -38,20 +38,6 @@ void GLContext::ScopedReleaseCurrent::Cancel() {
canceled_ = true;
}
-GLContext::FlushEvent::FlushEvent() {
-}
-
-GLContext::FlushEvent::~FlushEvent() {
-}
-
-void GLContext::FlushEvent::Signal() {
- flag_.Set();
-}
-
-bool GLContext::FlushEvent::IsSignaled() {
- return flag_.IsSet();
-}
-
GLContext::GLContext(GLShareGroup* share_group) :
share_group_(share_group),
swap_interval_(1),
@@ -69,13 +55,6 @@ GLContext::~GLContext() {
}
}
-scoped_refptr<GLContext::FlushEvent> GLContext::SignalFlush() {
- DCHECK(IsCurrent(NULL));
- scoped_refptr<FlushEvent> flush_event = new FlushEvent();
- flush_events_.push_back(flush_event);
- return flush_event;
-}
-
bool GLContext::GetTotalGpuMemory(size_t* bytes) {
DCHECK(bytes);
*bytes = 0;
@@ -230,12 +209,6 @@ void GLContext::SetRealGLApi() {
SetGLToRealGLApi();
}
-void GLContext::OnFlush() {
- for (size_t n = 0; n < flush_events_.size(); n++)
- flush_events_[n]->Signal();
- flush_events_.clear();
-}
-
GLContextReal::GLContextReal(GLShareGroup* share_group)
: GLContext(share_group) {}
diff --git a/ui/gl/gl_context.h b/ui/gl/gl_context.h
index 62cabcd..5eac838 100644
--- a/ui/gl/gl_context.h
+++ b/ui/gl/gl_context.h
@@ -34,25 +34,6 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
virtual bool Initialize(
GLSurface* compatible_surface, GpuPreference gpu_preference) = 0;
- class FlushEvent : public base::RefCountedThreadSafe<FlushEvent> {
- public:
- bool IsSignaled();
-
- private:
- friend class base::RefCountedThreadSafe<FlushEvent>;
- friend class GLContext;
- FlushEvent();
- virtual ~FlushEvent();
- void Signal();
-
- base::CancellationFlag flag_;
- };
-
- // Needs to be called with this context current. It will return a FlushEvent
- // that is initially unsignaled, but will transition to signaled after the
- // next glFlush() or glFinish() occurs in this context.
- scoped_refptr<FlushEvent> SignalFlush();
-
// Destroys the GL context.
virtual void Destroy() = 0;
@@ -143,9 +124,6 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
// Returns the GL renderer string. The context must be current.
virtual std::string GetGLRenderer();
- // Called when glFlush()/glFinish() is called with this context current.
- void OnFlush();
-
protected:
virtual ~GLContext();
@@ -186,8 +164,6 @@ class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
scoped_ptr<GLStateRestorer> state_restorer_;
scoped_ptr<GLVersionInfo> version_info_;
- std::vector<scoped_refptr<FlushEvent> > flush_events_;
-
int swap_interval_;
bool force_swap_interval_zero_;
diff --git a/ui/gl/gl_fence.cc b/ui/gl/gl_fence.cc
index c254411..0fb3a74 100644
--- a/ui/gl/gl_fence.cc
+++ b/ui/gl/gl_fence.cc
@@ -19,35 +19,6 @@
namespace gfx {
-namespace {
-
-// static
-GLFence* CreateFence(bool flush) {
- DCHECK(GLContext::GetCurrent())
- << "Trying to create fence with no context";
-
- scoped_ptr<GLFence> fence;
- // Prefer ARB_sync which supports server-side wait.
- if (g_driver_gl.ext.b_GL_ARB_sync ||
- GetGLVersionInfo()->is_es3) {
- fence.reset(new GLFenceARB(flush));
-#if defined(OS_MACOSX)
- } else if (g_driver_gl.ext.b_GL_APPLE_fence) {
- fence.reset(new GLFenceAPPLE(flush));
-#else
- } else if (g_driver_egl.ext.b_EGL_KHR_fence_sync) {
- fence.reset(new GLFenceEGL(flush));
-#endif
- } else if (g_driver_gl.ext.b_GL_NV_fence) {
- fence.reset(new GLFenceNV(flush));
- }
-
- DCHECK_EQ(!!fence.get(), GLFence::IsSupported());
- return fence.release();
-}
-
-} // namespace
-
GLFence::GLFence() {
}
@@ -66,11 +37,27 @@ bool GLFence::IsSupported() {
}
GLFence* GLFence::Create() {
- return CreateFence(true);
-}
+ DCHECK(GLContext::GetCurrent())
+ << "Trying to create fence with no context";
-GLFence* GLFence::CreateWithoutFlush() {
- return CreateFence(false);
+ scoped_ptr<GLFence> fence;
+ // Prefer ARB_sync which supports server-side wait.
+ if (g_driver_gl.ext.b_GL_ARB_sync ||
+ GetGLVersionInfo()->is_es3) {
+ fence.reset(new GLFenceARB);
+#if defined(OS_MACOSX)
+ } else if (g_driver_gl.ext.b_GL_APPLE_fence) {
+ fence.reset(new GLFenceAPPLE);
+#else
+ } else if (g_driver_egl.ext.b_EGL_KHR_fence_sync) {
+ fence.reset(new GLFenceEGL);
+#endif
+ } else if (g_driver_gl.ext.b_GL_NV_fence) {
+ fence.reset(new GLFenceNV);
+ }
+
+ DCHECK_EQ(!!fence.get(), GLFence::IsSupported());
+ return fence.release();
}
} // namespace gfx
diff --git a/ui/gl/gl_fence.h b/ui/gl/gl_fence.h
index 5af253d..76511f4 100644
--- a/ui/gl/gl_fence.h
+++ b/ui/gl/gl_fence.h
@@ -18,12 +18,6 @@ class GL_EXPORT GLFence {
static bool IsSupported();
static GLFence* Create();
- // Creates a fence that is not guaranteed to signal until the current context
- // is flushed. It is illegal to call Client/ServerWait() on a fence without
- // having explicitly called glFlush() or glFinish() in the originating
- // context.
- static GLFence* CreateWithoutFlush();
-
virtual bool HasCompleted() = 0;
virtual void ClientWait() = 0;
diff --git a/ui/gl/gl_fence_apple.cc b/ui/gl/gl_fence_apple.cc
index 9df0cad..3b5f697 100644
--- a/ui/gl/gl_fence_apple.cc
+++ b/ui/gl/gl_fence_apple.cc
@@ -5,19 +5,14 @@
#include "ui/gl/gl_fence_apple.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
namespace gfx {
-GLFenceAPPLE::GLFenceAPPLE(bool flush) {
+GLFenceAPPLE::GLFenceAPPLE() {
glGenFencesAPPLE(1, &fence_);
glSetFenceAPPLE(fence_);
DCHECK(glIsFenceAPPLE(fence_));
- if (flush) {
- glFlush();
- } else {
- flush_event_ = GLContext::GetCurrent()->SignalFlush();
- }
+ glFlush();
}
bool GLFenceAPPLE::HasCompleted() {
@@ -27,11 +22,7 @@ bool GLFenceAPPLE::HasCompleted() {
void GLFenceAPPLE::ClientWait() {
DCHECK(glIsFenceAPPLE(fence_));
- if (!flush_event_.get() || flush_event_->IsSignaled()) {
- glFinishFenceAPPLE(fence_);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ glFinishFenceAPPLE(fence_);
}
void GLFenceAPPLE::ServerWait() {
diff --git a/ui/gl/gl_fence_apple.h b/ui/gl/gl_fence_apple.h
index 6c8633d..5458e0d 100644
--- a/ui/gl/gl_fence_apple.h
+++ b/ui/gl/gl_fence_apple.h
@@ -7,14 +7,13 @@
#include "base/macros.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
#include "ui/gl/gl_fence.h"
namespace gfx {
class GL_EXPORT GLFenceAPPLE : public GLFence {
public:
- GLFenceAPPLE(bool flush);
+ GLFenceAPPLE();
~GLFenceAPPLE() override;
// GLFence implementation:
@@ -24,7 +23,6 @@ class GL_EXPORT GLFenceAPPLE : public GLFence {
private:
GLuint fence_;
- scoped_refptr<GLContext::FlushEvent> flush_event_;
DISALLOW_COPY_AND_ASSIGN(GLFenceAPPLE);
};
diff --git a/ui/gl/gl_fence_arb.cc b/ui/gl/gl_fence_arb.cc
index 05bda6b..5c6b337 100644
--- a/ui/gl/gl_fence_arb.cc
+++ b/ui/gl/gl_fence_arb.cc
@@ -6,7 +6,6 @@
#include "base/strings/stringprintf.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
namespace gfx {
@@ -24,14 +23,10 @@ std::string GetGLErrors() {
} // namespace
-GLFenceARB::GLFenceARB(bool flush) {
+GLFenceARB::GLFenceARB() {
sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
DCHECK_EQ(GL_TRUE, glIsSync(sync_));
- if (flush) {
- glFlush();
- } else {
- flush_event_ = GLContext::GetCurrent()->SignalFlush();
- }
+ glFlush();
}
bool GLFenceARB::HasCompleted() {
@@ -52,25 +47,17 @@ bool GLFenceARB::HasCompleted() {
void GLFenceARB::ClientWait() {
DCHECK_EQ(GL_TRUE, glIsSync(sync_));
- if (!flush_event_.get() || flush_event_->IsSignaled()) {
- GLenum result =
- glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
- DCHECK_NE(static_cast<GLenum>(GL_TIMEOUT_EXPIRED), result);
- if (result == GL_WAIT_FAILED) {
- LOG(FATAL) << "Failed to wait for GLFence. error code:" << GetGLErrors();
- }
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
+ GLenum result =
+ glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
+ DCHECK_NE(static_cast<GLenum>(GL_TIMEOUT_EXPIRED), result);
+ if (result == GL_WAIT_FAILED) {
+ LOG(FATAL) << "Failed to wait for GLFence. error code:" << GetGLErrors();
}
}
void GLFenceARB::ServerWait() {
DCHECK_EQ(GL_TRUE, glIsSync(sync_));
- if (!flush_event_.get() || flush_event_->IsSignaled()) {
- glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED);
}
GLFenceARB::~GLFenceARB() {
diff --git a/ui/gl/gl_fence_arb.h b/ui/gl/gl_fence_arb.h
index ef439487..3975efe 100644
--- a/ui/gl/gl_fence_arb.h
+++ b/ui/gl/gl_fence_arb.h
@@ -7,14 +7,13 @@
#include "base/macros.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
#include "ui/gl/gl_fence.h"
namespace gfx {
class GL_EXPORT GLFenceARB : public GLFence {
public:
- GLFenceARB(bool flush);
+ GLFenceARB();
~GLFenceARB() override;
// GLFence implementation:
@@ -24,7 +23,6 @@ class GL_EXPORT GLFenceARB : public GLFence {
private:
GLsync sync_;
- scoped_refptr<GLContext::FlushEvent> flush_event_;
DISALLOW_COPY_AND_ASSIGN(GLFenceARB);
};
diff --git a/ui/gl/gl_fence_egl.cc b/ui/gl/gl_fence_egl.cc
index c96d6d8..277b631 100644
--- a/ui/gl/gl_fence_egl.cc
+++ b/ui/gl/gl_fence_egl.cc
@@ -6,19 +6,14 @@
#include "ui/gl/egl_util.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
namespace gfx {
-GLFenceEGL::GLFenceEGL(bool flush) {
+GLFenceEGL::GLFenceEGL() {
display_ = eglGetCurrentDisplay();
sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL);
DCHECK(sync_ != EGL_NO_SYNC_KHR);
- if (flush) {
- glFlush();
- } else {
- flush_event_ = GLContext::GetCurrent()->SignalFlush();
- }
+ glFlush();
}
bool GLFenceEGL::HasCompleted() {
@@ -35,17 +30,13 @@ bool GLFenceEGL::HasCompleted() {
}
void GLFenceEGL::ClientWait() {
- if (!flush_event_.get() || flush_event_->IsSignaled()) {
- EGLint flags = 0;
- EGLTimeKHR time = EGL_FOREVER_KHR;
- EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time);
- DCHECK_NE(EGL_TIMEOUT_EXPIRED_KHR, result);
- if (result == EGL_FALSE) {
- LOG(FATAL) << "Failed to wait for EGLSync. error:"
- << ui::GetLastEGLErrorString();
- }
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
+ EGLint flags = 0;
+ EGLTimeKHR time = EGL_FOREVER_KHR;
+ EGLint result = eglClientWaitSyncKHR(display_, sync_, flags, time);
+ DCHECK_NE(EGL_TIMEOUT_EXPIRED_KHR, result);
+ if (result == EGL_FALSE) {
+ LOG(FATAL) << "Failed to wait for EGLSync. error:"
+ << ui::GetLastEGLErrorString();
}
}
@@ -54,14 +45,10 @@ void GLFenceEGL::ServerWait() {
ClientWait();
return;
}
- if (!flush_event_.get() || flush_event_->IsSignaled()) {
- EGLint flags = 0;
- if (eglWaitSyncKHR(display_, sync_, flags) == EGL_FALSE) {
- LOG(FATAL) << "Failed to wait for EGLSync. error:"
- << ui::GetLastEGLErrorString();
- }
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
+ EGLint flags = 0;
+ if (eglWaitSyncKHR(display_, sync_, flags) == EGL_FALSE) {
+ LOG(FATAL) << "Failed to wait for EGLSync. error:"
+ << ui::GetLastEGLErrorString();
}
}
diff --git a/ui/gl/gl_fence_egl.h b/ui/gl/gl_fence_egl.h
index 75a0444..5c4defb 100644
--- a/ui/gl/gl_fence_egl.h
+++ b/ui/gl/gl_fence_egl.h
@@ -7,14 +7,13 @@
#include "base/macros.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
#include "ui/gl/gl_fence.h"
namespace gfx {
class GL_EXPORT GLFenceEGL : public GLFence {
public:
- GLFenceEGL(bool flush);
+ GLFenceEGL();
~GLFenceEGL() override;
// GLFence implementation:
@@ -25,7 +24,6 @@ class GL_EXPORT GLFenceEGL : public GLFence {
private:
EGLSyncKHR sync_;
EGLDisplay display_;
- scoped_refptr<GLContext::FlushEvent> flush_event_;
DISALLOW_COPY_AND_ASSIGN(GLFenceEGL);
};
diff --git a/ui/gl/gl_fence_nv.cc b/ui/gl/gl_fence_nv.cc
index 46dadd5..0e23b28 100644
--- a/ui/gl/gl_fence_nv.cc
+++ b/ui/gl/gl_fence_nv.cc
@@ -5,11 +5,10 @@
#include "ui/gl/gl_fence_nv.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
namespace gfx {
-GLFenceNV::GLFenceNV(bool flush) {
+GLFenceNV::GLFenceNV() {
// What if either of these GL calls fails? TestFenceNV will return true.
// See spec:
// http://www.opengl.org/registry/specs/NV/fence.txt
@@ -23,11 +22,7 @@ GLFenceNV::GLFenceNV(bool flush) {
glGenFencesNV(1, &fence_);
glSetFenceNV(fence_, GL_ALL_COMPLETED_NV);
DCHECK(glIsFenceNV(fence_));
- if (flush) {
- glFlush();
- } else {
- flush_event_ = GLContext::GetCurrent()->SignalFlush();
- }
+ glFlush();
}
bool GLFenceNV::HasCompleted() {
@@ -37,11 +32,7 @@ bool GLFenceNV::HasCompleted() {
void GLFenceNV::ClientWait() {
DCHECK(glIsFenceNV(fence_));
- if (!flush_event_.get() || flush_event_->IsSignaled()) {
- glFinishFenceNV(fence_);
- } else {
- LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping...";
- }
+ glFinishFenceNV(fence_);
}
void GLFenceNV::ServerWait() {
diff --git a/ui/gl/gl_fence_nv.h b/ui/gl/gl_fence_nv.h
index 0bac11c..b1dc88f 100644
--- a/ui/gl/gl_fence_nv.h
+++ b/ui/gl/gl_fence_nv.h
@@ -7,14 +7,13 @@
#include "base/macros.h"
#include "ui/gl/gl_bindings.h"
-#include "ui/gl/gl_context.h"
#include "ui/gl/gl_fence.h"
namespace gfx {
class GL_EXPORT GLFenceNV : public GLFence {
public:
- GLFenceNV(bool flush);
+ GLFenceNV();
~GLFenceNV() override;
// GLFence implementation:
@@ -24,7 +23,6 @@ class GL_EXPORT GLFenceNV : public GLFence {
private:
GLuint fence_;
- scoped_refptr<GLContext::FlushEvent> flush_event_;
DISALLOW_COPY_AND_ASSIGN(GLFenceNV);
};
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index fada5e3..81a1b72 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -395,11 +395,6 @@ void GLApiBase::InitializeBase(DriverGL* driver) {
driver_ = driver;
}
-void GLApiBase::SignalFlush() {
- DCHECK(GLContext::GetCurrent());
- GLContext::GetCurrent()->OnFlush();
-}
-
RealGLApi::RealGLApi() {
}
@@ -412,12 +407,10 @@ void RealGLApi::Initialize(DriverGL* driver) {
void RealGLApi::glFlushFn() {
GLApiBase::glFlushFn();
- GLApiBase::SignalFlush();
}
void RealGLApi::glFinishFn() {
GLApiBase::glFinishFn();
- GLApiBase::SignalFlush();
}
TraceGLApi::~TraceGLApi() {
@@ -525,12 +518,10 @@ const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
void VirtualGLApi::glFlushFn() {
GLApiBase::glFlushFn();
- GLApiBase::SignalFlush();
}
void VirtualGLApi::glFinishFn() {
GLApiBase::glFinishFn();
- GLApiBase::SignalFlush();
}
ScopedSetGLToRealGLApi::ScopedSetGLToRealGLApi()
diff --git a/ui/gl/gl_gl_api_implementation.h b/ui/gl/gl_gl_api_implementation.h
index 1b23097..d408600 100644
--- a/ui/gl/gl_gl_api_implementation.h
+++ b/ui/gl/gl_gl_api_implementation.h
@@ -44,7 +44,6 @@ class GLApiBase : public GLApi {
GLApiBase();
~GLApiBase() override;
void InitializeBase(DriverGL* driver);
- void SignalFlush();
DriverGL* driver_;
};