Commit 4aa353f4 authored by Kramer Ge's avatar Kramer Ge Committed by Commit Bot

Remove GLSurface::GetCompatibilityKey

We use one X visual and thus all GLContexts are compatible with each
other and this method is not needed.

Bug: 902943
Change-Id: I51d8f7527b52117c0b1535cc7f3d706030c3ffda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001397
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarPeng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732275}
parent a13341ac
...@@ -49,7 +49,7 @@ TEST_F(GLContextVirtualTest, Reinitialize) { ...@@ -49,7 +49,7 @@ TEST_F(GLContextVirtualTest, Reinitialize) {
{ {
auto base_context = base::MakeRefCounted<gl::GLContextStub>(); auto base_context = base::MakeRefCounted<gl::GLContextStub>();
gl::GLShareGroup* share_group = base_context->share_group(); gl::GLShareGroup* share_group = base_context->share_group();
share_group->SetSharedContext(GetGLSurface(), base_context.get()); share_group->SetSharedContext(base_context.get());
auto context = base::MakeRefCounted<GLContextVirtual>( auto context = base::MakeRefCounted<GLContextVirtual>(
share_group, base_context.get(), decoder_->AsWeakPtr()); share_group, base_context.get(), decoder_->AsWeakPtr());
EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs())); EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs()));
...@@ -58,7 +58,7 @@ TEST_F(GLContextVirtualTest, Reinitialize) { ...@@ -58,7 +58,7 @@ TEST_F(GLContextVirtualTest, Reinitialize) {
{ {
auto base_context = base::MakeRefCounted<gl::GLContextStub>(); auto base_context = base::MakeRefCounted<gl::GLContextStub>();
gl::GLShareGroup* share_group = base_context->share_group(); gl::GLShareGroup* share_group = base_context->share_group();
share_group->SetSharedContext(GetGLSurface(), base_context.get()); share_group->SetSharedContext(base_context.get());
auto context = base::MakeRefCounted<GLContextVirtual>( auto context = base::MakeRefCounted<GLContextVirtual>(
share_group, base_context.get(), decoder_->AsWeakPtr()); share_group, base_context.get(), decoder_->AsWeakPtr());
EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs())); EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs()));
...@@ -77,7 +77,7 @@ TEST_F(GLContextVirtualTest, CheckStickyGraphicsResetStatus) { ...@@ -77,7 +77,7 @@ TEST_F(GLContextVirtualTest, CheckStickyGraphicsResetStatus) {
base_context->SetExtensionsString(gl_extensions); base_context->SetExtensionsString(gl_extensions);
gl::GLShareGroup* share_group = base_context->share_group(); gl::GLShareGroup* share_group = base_context->share_group();
share_group->SetSharedContext(GetGLSurface(), base_context.get()); share_group->SetSharedContext(base_context.get());
auto context = base::MakeRefCounted<GLContextVirtual>( auto context = base::MakeRefCounted<GLContextVirtual>(
share_group, base_context.get(), decoder_->AsWeakPtr()); share_group, base_context.get(), decoder_->AsWeakPtr());
EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs())); EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs()));
......
...@@ -659,9 +659,8 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread( ...@@ -659,9 +659,8 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
// TODO(khushalsagar): A lot of this initialization code is duplicated in // TODO(khushalsagar): A lot of this initialization code is duplicated in
// GpuChannelManager. Pull it into a common util method. // GpuChannelManager. Pull it into a common util method.
scoped_refptr<gl::GLContext> real_context = scoped_refptr<gl::GLContext> real_context =
use_virtualized_gl_context_ use_virtualized_gl_context_ ? gl_share_group_->shared_context()
? gl_share_group_->GetSharedContext(surface_.get()) : nullptr;
: nullptr;
if (real_context && if (real_context &&
(!real_context->MakeCurrent(surface_.get()) || (!real_context->MakeCurrent(surface_.get()) ||
real_context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) { real_context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) {
...@@ -686,7 +685,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread( ...@@ -686,7 +685,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
task_executor_->gpu_feature_info().ApplyToGLContext(real_context.get()); task_executor_->gpu_feature_info().ApplyToGLContext(real_context.get());
if (use_virtualized_gl_context_) if (use_virtualized_gl_context_)
gl_share_group_->SetSharedContext(surface_.get(), real_context.get()); gl_share_group_->SetSharedContext(real_context.get());
} }
if (!real_context->MakeCurrent(surface_.get())) { if (!real_context->MakeCurrent(surface_.get())) {
......
...@@ -261,7 +261,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize( ...@@ -261,7 +261,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize(
scoped_refptr<gl::GLContext> context; scoped_refptr<gl::GLContext> context;
if (use_virtualized_gl_context_ && share_group_) { if (use_virtualized_gl_context_ && share_group_) {
context = share_group_->GetSharedContext(surface_.get()); context = share_group_->shared_context();
if (context && (!context->MakeCurrent(surface_.get()) || if (context && (!context->MakeCurrent(surface_.get()) ||
context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) { context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) {
context = nullptr; context = nullptr;
...@@ -281,7 +281,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize( ...@@ -281,7 +281,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize(
// Ensure that context creation did not lose track of the intended share // Ensure that context creation did not lose track of the intended share
// group. // group.
DCHECK(context->share_group() == share_group_.get()); DCHECK(context->share_group() == share_group_.get());
share_group_->SetSharedContext(surface_.get(), context.get()); share_group_->SetSharedContext(context.get());
// This needs to be called against the real shared context, not the // This needs to be called against the real shared context, not the
// virtual context created below. // virtual context created below.
......
...@@ -461,8 +461,7 @@ scoped_refptr<SharedContextState> GpuChannelManager::GetSharedContextState( ...@@ -461,8 +461,7 @@ scoped_refptr<SharedContextState> GpuChannelManager::GetSharedContextState(
} }
scoped_refptr<gl::GLContext> context = scoped_refptr<gl::GLContext> context =
use_virtualized_gl_contexts ? share_group->GetSharedContext(surface.get()) use_virtualized_gl_contexts ? share_group->shared_context() : nullptr;
: nullptr;
if (context && (!context->MakeCurrent(surface.get()) || if (context && (!context->MakeCurrent(surface.get()) ||
context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) { context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) {
context = nullptr; context = nullptr;
...@@ -487,7 +486,7 @@ scoped_refptr<SharedContextState> GpuChannelManager::GetSharedContextState( ...@@ -487,7 +486,7 @@ scoped_refptr<SharedContextState> GpuChannelManager::GetSharedContextState(
gpu_feature_info_.ApplyToGLContext(context.get()); gpu_feature_info_.ApplyToGLContext(context.get());
if (use_virtualized_gl_contexts) if (use_virtualized_gl_contexts)
share_group->SetSharedContext(surface.get(), context.get()); share_group->SetSharedContext(context.get());
} }
// This should be either: // This should be either:
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
namespace gl { namespace gl {
...@@ -25,12 +24,8 @@ void GLShareGroup::AddContext(GLContext* context) { ...@@ -25,12 +24,8 @@ void GLShareGroup::AddContext(GLContext* context) {
void GLShareGroup::RemoveContext(GLContext* context) { void GLShareGroup::RemoveContext(GLContext* context) {
contexts_.erase(context); contexts_.erase(context);
for (const auto& pair : shared_contexts_) { if (shared_context_ == context)
if (pair.second == context) { shared_context_ = nullptr;
shared_contexts_.erase(pair.first);
return;
}
}
} }
void* GLShareGroup::GetHandle() { void* GLShareGroup::GetHandle() {
...@@ -50,17 +45,9 @@ GLContext* GLShareGroup::GetContext() { ...@@ -50,17 +45,9 @@ GLContext* GLShareGroup::GetContext() {
return NULL; return NULL;
} }
void GLShareGroup::SetSharedContext(GLSurface* compatible, GLContext* context) { void GLShareGroup::SetSharedContext(GLContext* context) {
DCHECK(contexts_.find(context) != contexts_.end()); DCHECK(contexts_.find(context) != contexts_.end());
shared_contexts_[compatible->GetCompatibilityKey()] = context; shared_context_ = context;
}
GLContext* GLShareGroup::GetSharedContext(GLSurface* compatible) {
unsigned long compatibility_key = compatible->GetCompatibilityKey();
auto it = shared_contexts_.find(compatibility_key);
if (it == shared_contexts_.end())
return nullptr;
return it->second;
} }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <set> #include <set>
#include <unordered_map> #include <unordered_map>
#include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -16,7 +17,6 @@ ...@@ -16,7 +17,6 @@
namespace gl { namespace gl {
class GLContext; class GLContext;
class GLSurface;
// A group of GL contexts that share an ID namespace. // A group of GL contexts that share an ID namespace.
class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> { class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
...@@ -37,8 +37,8 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> { ...@@ -37,8 +37,8 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
GLContext* GetContext(); GLContext* GetContext();
// Sets and returns the shared GL context. Used for context virtualization. // Sets and returns the shared GL context. Used for context virtualization.
void SetSharedContext(GLSurface* compatible, GLContext* context); void SetSharedContext(GLContext* context);
GLContext* GetSharedContext(GLSurface* compatible); GLContext* shared_context() { return shared_context_; }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Sets and returns the ID of the renderer that all contexts in this share // Sets and returns the ID of the renderer that all contexts in this share
...@@ -57,7 +57,7 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> { ...@@ -57,7 +57,7 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
typedef std::set<GLContext*> ContextSet; typedef std::set<GLContext*> ContextSet;
ContextSet contexts_; ContextSet contexts_;
std::unordered_map<unsigned long, GLContext*> shared_contexts_; GLContext* shared_context_ = nullptr;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
int renderer_id_; int renderer_id_;
......
...@@ -139,10 +139,6 @@ void* GLSurface::GetConfig() { ...@@ -139,10 +139,6 @@ void* GLSurface::GetConfig() {
return NULL; return NULL;
} }
unsigned long GLSurface::GetCompatibilityKey() {
return 0;
}
gfx::VSyncProvider* GLSurface::GetVSyncProvider() { gfx::VSyncProvider* GLSurface::GetVSyncProvider() {
return NULL; return NULL;
} }
...@@ -418,10 +414,6 @@ void* GLSurfaceAdapter::GetConfig() { ...@@ -418,10 +414,6 @@ void* GLSurfaceAdapter::GetConfig() {
return surface_->GetConfig(); return surface_->GetConfig();
} }
unsigned long GLSurfaceAdapter::GetCompatibilityKey() {
return surface_->GetCompatibilityKey();
}
GLSurfaceFormat GLSurfaceAdapter::GetFormat() { GLSurfaceFormat GLSurfaceAdapter::GetFormat() {
return surface_->GetFormat(); return surface_->GetFormat();
} }
......
...@@ -197,10 +197,6 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { ...@@ -197,10 +197,6 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
// Get the platfrom specific configuration for this surface, if available. // Get the platfrom specific configuration for this surface, if available.
virtual void* GetConfig(); virtual void* GetConfig();
// Get the key corresponding to the set of GLSurfaces that can be made current
// with this GLSurface.
virtual unsigned long GetCompatibilityKey();
// Get the GL pixel format of the surface. Must be implemented in a // Get the GL pixel format of the surface. Must be implemented in a
// subclass, though it's ok to just "return GLSurfaceFormat()" if // subclass, though it's ok to just "return GLSurfaceFormat()" if
// the default is appropriate. // the default is appropriate.
...@@ -371,7 +367,6 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface { ...@@ -371,7 +367,6 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface {
void* GetShareHandle() override; void* GetShareHandle() override;
void* GetDisplay() override; void* GetDisplay() override;
void* GetConfig() override; void* GetConfig() override;
unsigned long GetCompatibilityKey() override;
GLSurfaceFormat GetFormat() override; GLSurfaceFormat GetFormat() override;
gfx::VSyncProvider* GetVSyncProvider() override; gfx::VSyncProvider* GetVSyncProvider() override;
void SetVSyncEnabled(bool enabled) override; void SetVSyncEnabled(bool enabled) override;
......
...@@ -750,10 +750,6 @@ GLSurfaceFormat NativeViewGLSurfaceGLX::GetFormat() { ...@@ -750,10 +750,6 @@ GLSurfaceFormat NativeViewGLSurfaceGLX::GetFormat() {
return GLSurfaceFormat(); return GLSurfaceFormat();
} }
unsigned long NativeViewGLSurfaceGLX::GetCompatibilityKey() {
return XVisualIDFromVisual(g_visual);
}
gfx::SwapResult NativeViewGLSurfaceGLX::PostSubBuffer( gfx::SwapResult NativeViewGLSurfaceGLX::PostSubBuffer(
int x, int x,
int y, int y,
...@@ -888,10 +884,6 @@ GLSurfaceFormat UnmappedNativeViewGLSurfaceGLX::GetFormat() { ...@@ -888,10 +884,6 @@ GLSurfaceFormat UnmappedNativeViewGLSurfaceGLX::GetFormat() {
return GLSurfaceFormat(); return GLSurfaceFormat();
} }
unsigned long UnmappedNativeViewGLSurfaceGLX::GetCompatibilityKey() {
return XVisualIDFromVisual(g_visual);
}
UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() { UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() {
Destroy(); Destroy();
} }
......
...@@ -55,8 +55,6 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface { ...@@ -55,8 +55,6 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface {
// a GLX drawable. // a GLX drawable.
void* GetConfig() override = 0; void* GetConfig() override = 0;
unsigned long GetCompatibilityKey() override = 0;
protected: protected:
~GLSurfaceGLX() override; ~GLSurfaceGLX() override;
...@@ -84,7 +82,6 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX { ...@@ -84,7 +82,6 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX {
bool SupportsPostSubBuffer() override; bool SupportsPostSubBuffer() override;
void* GetConfig() override; void* GetConfig() override;
GLSurfaceFormat GetFormat() override; GLSurfaceFormat GetFormat() override;
unsigned long GetCompatibilityKey() override;
gfx::SwapResult PostSubBuffer(int x, gfx::SwapResult PostSubBuffer(int x,
int y, int y,
int width, int width,
...@@ -148,7 +145,6 @@ class GL_EXPORT UnmappedNativeViewGLSurfaceGLX : public GLSurfaceGLX { ...@@ -148,7 +145,6 @@ class GL_EXPORT UnmappedNativeViewGLSurfaceGLX : public GLSurfaceGLX {
void* GetHandle() override; void* GetHandle() override;
void* GetConfig() override; void* GetConfig() override;
GLSurfaceFormat GetFormat() override; GLSurfaceFormat GetFormat() override;
unsigned long GetCompatibilityKey() override;
protected: protected:
~UnmappedNativeViewGLSurfaceGLX() override; ~UnmappedNativeViewGLSurfaceGLX() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment