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) {
{
auto base_context = base::MakeRefCounted<gl::GLContextStub>();
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>(
share_group, base_context.get(), decoder_->AsWeakPtr());
EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs()));
......@@ -58,7 +58,7 @@ TEST_F(GLContextVirtualTest, Reinitialize) {
{
auto base_context = base::MakeRefCounted<gl::GLContextStub>();
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>(
share_group, base_context.get(), decoder_->AsWeakPtr());
EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs()));
......@@ -77,7 +77,7 @@ TEST_F(GLContextVirtualTest, CheckStickyGraphicsResetStatus) {
base_context->SetExtensionsString(gl_extensions);
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>(
share_group, base_context.get(), decoder_->AsWeakPtr());
EXPECT_TRUE(context->Initialize(GetGLSurface(), gl::GLContextAttribs()));
......
......@@ -659,8 +659,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
// TODO(khushalsagar): A lot of this initialization code is duplicated in
// GpuChannelManager. Pull it into a common util method.
scoped_refptr<gl::GLContext> real_context =
use_virtualized_gl_context_
? gl_share_group_->GetSharedContext(surface_.get())
use_virtualized_gl_context_ ? gl_share_group_->shared_context()
: nullptr;
if (real_context &&
(!real_context->MakeCurrent(surface_.get()) ||
......@@ -686,7 +685,7 @@ gpu::ContextResult InProcessCommandBuffer::InitializeOnGpuThread(
task_executor_->gpu_feature_info().ApplyToGLContext(real_context.get());
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())) {
......
......@@ -261,7 +261,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize(
scoped_refptr<gl::GLContext> context;
if (use_virtualized_gl_context_ && share_group_) {
context = share_group_->GetSharedContext(surface_.get());
context = share_group_->shared_context();
if (context && (!context->MakeCurrent(surface_.get()) ||
context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) {
context = nullptr;
......@@ -281,7 +281,7 @@ gpu::ContextResult GLES2CommandBufferStub::Initialize(
// Ensure that context creation did not lose track of the intended share
// group.
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
// virtual context created below.
......
......@@ -461,8 +461,7 @@ scoped_refptr<SharedContextState> GpuChannelManager::GetSharedContextState(
}
scoped_refptr<gl::GLContext> context =
use_virtualized_gl_contexts ? share_group->GetSharedContext(surface.get())
: nullptr;
use_virtualized_gl_contexts ? share_group->shared_context() : nullptr;
if (context && (!context->MakeCurrent(surface.get()) ||
context->CheckStickyGraphicsResetStatus() != GL_NO_ERROR)) {
context = nullptr;
......@@ -487,7 +486,7 @@ scoped_refptr<SharedContextState> GpuChannelManager::GetSharedContextState(
gpu_feature_info_.ApplyToGLContext(context.get());
if (use_virtualized_gl_contexts)
share_group->SetSharedContext(surface.get(), context.get());
share_group->SetSharedContext(context.get());
}
// This should be either:
......
......@@ -8,7 +8,6 @@
#include "build/build_config.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
namespace gl {
......@@ -25,12 +24,8 @@ void GLShareGroup::AddContext(GLContext* context) {
void GLShareGroup::RemoveContext(GLContext* context) {
contexts_.erase(context);
for (const auto& pair : shared_contexts_) {
if (pair.second == context) {
shared_contexts_.erase(pair.first);
return;
}
}
if (shared_context_ == context)
shared_context_ = nullptr;
}
void* GLShareGroup::GetHandle() {
......@@ -50,17 +45,9 @@ GLContext* GLShareGroup::GetContext() {
return NULL;
}
void GLShareGroup::SetSharedContext(GLSurface* compatible, GLContext* context) {
void GLShareGroup::SetSharedContext(GLContext* context) {
DCHECK(contexts_.find(context) != contexts_.end());
shared_contexts_[compatible->GetCompatibilityKey()] = 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;
shared_context_ = context;
}
#if defined(OS_MACOSX)
......
......@@ -8,6 +8,7 @@
#include <set>
#include <unordered_map>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
......@@ -16,7 +17,6 @@
namespace gl {
class GLContext;
class GLSurface;
// A group of GL contexts that share an ID namespace.
class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
......@@ -37,8 +37,8 @@ class GL_EXPORT GLShareGroup : public base::RefCounted<GLShareGroup> {
GLContext* GetContext();
// Sets and returns the shared GL context. Used for context virtualization.
void SetSharedContext(GLSurface* compatible, GLContext* context);
GLContext* GetSharedContext(GLSurface* compatible);
void SetSharedContext(GLContext* context);
GLContext* shared_context() { return shared_context_; }
#if defined(OS_MACOSX)
// 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> {
typedef std::set<GLContext*> ContextSet;
ContextSet contexts_;
std::unordered_map<unsigned long, GLContext*> shared_contexts_;
GLContext* shared_context_ = nullptr;
#if defined(OS_MACOSX)
int renderer_id_;
......
......@@ -139,10 +139,6 @@ void* GLSurface::GetConfig() {
return NULL;
}
unsigned long GLSurface::GetCompatibilityKey() {
return 0;
}
gfx::VSyncProvider* GLSurface::GetVSyncProvider() {
return NULL;
}
......@@ -418,10 +414,6 @@ void* GLSurfaceAdapter::GetConfig() {
return surface_->GetConfig();
}
unsigned long GLSurfaceAdapter::GetCompatibilityKey() {
return surface_->GetCompatibilityKey();
}
GLSurfaceFormat GLSurfaceAdapter::GetFormat() {
return surface_->GetFormat();
}
......
......@@ -197,10 +197,6 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
// Get the platfrom specific configuration for this surface, if available.
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
// subclass, though it's ok to just "return GLSurfaceFormat()" if
// the default is appropriate.
......@@ -371,7 +367,6 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface {
void* GetShareHandle() override;
void* GetDisplay() override;
void* GetConfig() override;
unsigned long GetCompatibilityKey() override;
GLSurfaceFormat GetFormat() override;
gfx::VSyncProvider* GetVSyncProvider() override;
void SetVSyncEnabled(bool enabled) override;
......
......@@ -750,10 +750,6 @@ GLSurfaceFormat NativeViewGLSurfaceGLX::GetFormat() {
return GLSurfaceFormat();
}
unsigned long NativeViewGLSurfaceGLX::GetCompatibilityKey() {
return XVisualIDFromVisual(g_visual);
}
gfx::SwapResult NativeViewGLSurfaceGLX::PostSubBuffer(
int x,
int y,
......@@ -888,10 +884,6 @@ GLSurfaceFormat UnmappedNativeViewGLSurfaceGLX::GetFormat() {
return GLSurfaceFormat();
}
unsigned long UnmappedNativeViewGLSurfaceGLX::GetCompatibilityKey() {
return XVisualIDFromVisual(g_visual);
}
UnmappedNativeViewGLSurfaceGLX::~UnmappedNativeViewGLSurfaceGLX() {
Destroy();
}
......
......@@ -55,8 +55,6 @@ class GL_EXPORT GLSurfaceGLX : public GLSurface {
// a GLX drawable.
void* GetConfig() override = 0;
unsigned long GetCompatibilityKey() override = 0;
protected:
~GLSurfaceGLX() override;
......@@ -84,7 +82,6 @@ class GL_EXPORT NativeViewGLSurfaceGLX : public GLSurfaceGLX {
bool SupportsPostSubBuffer() override;
void* GetConfig() override;
GLSurfaceFormat GetFormat() override;
unsigned long GetCompatibilityKey() override;
gfx::SwapResult PostSubBuffer(int x,
int y,
int width,
......@@ -148,7 +145,6 @@ class GL_EXPORT UnmappedNativeViewGLSurfaceGLX : public GLSurfaceGLX {
void* GetHandle() override;
void* GetConfig() override;
GLSurfaceFormat GetFormat() override;
unsigned long GetCompatibilityKey() override;
protected:
~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