Skip to content

Commit

Permalink
Revert 45240 - Moved GLContext class to gfx/gl.
Browse files Browse the repository at this point in the history
Now it can be used by code outside of the gpu project, for example AcceleratedSurface.

TEST=trybots
BUG=none

Review URL: http://codereview.chromium.org/1694003

TBR=jamesr@chromium.org
Review URL: http://codereview.chromium.org/1747007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45244 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
apatrick@chromium.org committed Apr 21, 2010
1 parent d3d0ef9 commit 96f8063
Show file tree
Hide file tree
Showing 20 changed files with 112 additions and 124 deletions.
24 changes: 0 additions & 24 deletions gfx/gfx.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -130,30 +130,6 @@
}],
],
},
{
'target_name': 'gfx_gl',
'type': 'static_library',
'include_dirs': [
'..',
'../third_party/glew/include',
],
'defines': [
'GLEW_STATIC',
],
'sources': [
'gl/gl_context.cc',
'gl/gl_context.h',
'gl/gl_context_osmesa.cc',
'gl/gl_context_osmesa.h',
'gl/gl_context_linux.cc',
'gl/gl_context_linux.h',
'gl/gl_context_mac.cc',
'gl/gl_context_mac.h',
'gl/gl_context_win.cc',
'gl/gl_context_win.h',
'../third_party/glew/src/glew.c',
],
},
],
}

Expand Down
15 changes: 10 additions & 5 deletions gfx/gl/gl_context.cc → gpu/command_buffer/service/gl_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <GL/glew.h>
#include "gpu/command_buffer/service/gl_context.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/common/logging.h"

#include "gfx/gl/gl_context.h"
#include "base/logging.h"
namespace gpu {

namespace gfx {
GLContext::GLContext() {
}

GLContext::~GLContext() {
}

// GLEW initialization is extremely expensive because it looks up
// hundreds of function pointers. Realistically we are not going to
Expand Down Expand Up @@ -83,4 +88,4 @@ bool GLContext::InitializeCommon() {

return true;
}
} // namespace gfx
} // namespace gpu
14 changes: 7 additions & 7 deletions gfx/gl/gl_context.h → gpu/command_buffer/service/gl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GFX_GL_GL_CONTEXT_H_
#define GFX_GL_GL_CONTEXT_H_
#ifndef GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_H_
#define GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_H_

#include "build/build_config.h"
#include "gfx/native_widget_types.h"
#include "gfx/size.h"
#include "gpu/command_buffer/common/logging.h"

namespace gfx {
namespace gpu {

bool InitializeGLEW();

// Encapsulates an OpenGL context, hiding platform specific management.
class GLContext {
public:
GLContext() {}
virtual ~GLContext() {}
GLContext();
virtual ~GLContext();

// Destroys the GL context.
virtual void Destroy() = 0;
Expand Down Expand Up @@ -59,6 +59,6 @@ class GLContext {
DISALLOW_COPY_AND_ASSIGN(GLContext);
};

} // namespace gfx
} // namespace gpu

#endif // GFX_GL_GL_CONTEXT_H_
#endif // GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
// This file implements the ViewGLContext and PbufferGLContext classes.

#include <dlfcn.h>
#include <GL/glew.h>
#include <GL/glxew.h>
#include <GL/glx.h>
#include <GL/osmew.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

// Ensure that gl_utils.h is included before any GL headers.
#include "gpu/command_buffer/service/gl_utils.h"

#include "app/x11_util.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "gfx/gl/gl_context.h"
#include "gfx/gl/gl_context_osmesa.h"
#include "gpu/command_buffer/service/gl_context.h"
#include "gpu/command_buffer/service/gl_context_osmesa.h"
#include "gpu/command_buffer/common/logging.h"

namespace gfx {
namespace gpu {

typedef GLXContext GLContextHandle;
typedef GLXPbuffer PbufferHandle;
Expand Down Expand Up @@ -399,4 +398,4 @@ GLContext* GLContext::CreateOffscreenGLContext(void* shared_handle) {
}
}

} // namespace gfx
} // namespace gpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

// This file implements the ViewGLContext and PbufferGLContext classes.

#include <GL/glew.h>
#include <GL/osmew.h>
#include <OpenGL/OpenGL.h>
// Ensure that gl_utils.h is included before any GL headers.
#include "gpu/command_buffer/service/gl_utils.h"

#include "app/surface/accelerated_surface_mac.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "gfx/gl/gl_context.h"
#include "gfx/gl/gl_context_osmesa.h"
#include "gpu/command_buffer/service/gl_context.h"
#include "gpu/command_buffer/service/gl_context_osmesa.h"
#include "gpu/command_buffer/common/logging.h"

namespace gfx {
namespace gpu {

typedef CGLContextObj GLContextHandle;
typedef CGLPBufferObj PbufferHandle;
Expand Down Expand Up @@ -180,4 +179,4 @@ GLContext* GLContext::CreateOffscreenGLContext(void* shared_handle) {
}
}

} // namespace gfx
} // namespace gpu
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <GL/glew.h>
#include <GL/osmew.h>

#include <algorithm>

#include "gfx/gl/gl_context_osmesa.h"
#include "gpu/command_buffer/service/gl_context_osmesa.h"

namespace gfx {
namespace gpu {

OSMesaGLContext::OSMesaGLContext()
#if !defined(UNIT_TEST)
Expand Down Expand Up @@ -106,4 +103,4 @@ void OSMesaGLContext::Resize(const gfx::Size& new_size) {
MakeCurrent();
}

} // namespace gfx
} // namespace gpu
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GFX_GL_GL_CONTEXT_OSMESA_H_
#define GFX_GL_GL_CONTEXT_OSMESA_H_
#ifndef GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_OSMESA_H_
#define GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_OSMESA_H_

// Ensure that gl_utils.h is included before any GL headers.
#include "gpu/command_buffer/service/gl_utils.h"

#include "base/scoped_ptr.h"
#include "gfx/size.h"
#include "gfx/gl/gl_context.h"

typedef struct osmesa_context *OSMesaContext;
#include "gpu/command_buffer/service/gl_context.h"

namespace gfx {
namespace gpu {

// Encapsulates an OSMesa OpenGL context that uses software rendering.
class OSMesaGLContext : public GLContext {
Expand Down Expand Up @@ -52,6 +53,6 @@ class OSMesaGLContext : public GLContext {
DISALLOW_COPY_AND_ASSIGN(OSMesaGLContext);
};

} // namespace gfx
} // namespace gpu

#endif // GFX_GL_GL_CONTEXT_OSMESA_H_
#endif // GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_OSMESA_H_
19 changes: 7 additions & 12 deletions gpu/command_buffer/service/gl_context_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// This file implements the StubGLContext.

#include "build/build_config.h"
#include "gfx/gl/gl_context.h"
#include "gpu/command_buffer/service/gl_context.h"

namespace gpu {

// A GLContext that does nothing for unit tests.
class StubGLContext : public gfx::GLContext {
class StubGLContext : public GLContext {
public:

// Implement GLContext.
Expand All @@ -23,22 +23,17 @@ class StubGLContext : public gfx::GLContext {
virtual void* GetHandle() { return NULL; }
};

} // namespace gpu

namespace gfx {

#if !defined(OS_MACOSX)

GLContext* GLContext::CreateViewGLContext(PluginWindowHandle /* window */,
GLContext* GLContext::CreateViewGLContext(gfx::PluginWindowHandle /* window */,
bool /* multisampled */) {
return new gpu::StubGLContext;
return new StubGLContext;
}

#endif // OS_MACOSX

GLContext* GLContext::CreateOffscreenGLContext(
void* /* shared_handle */) {
return new gpu::StubGLContext;
GLContext* GLContext::CreateOffscreenGLContext(void* /* shared_handle */) {
return new StubGLContext;
}

} // namespace gfx
} // namespace gpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@

// This file implements the NativeViewGLContext and PbufferGLContext classes.

#include <GL/glew.h>
#include <GL/osmew.h>
#include <GL/wglew.h>
#include <windows.h>

#include <algorithm>

#include "base/logging.h"
// Ensure that gl_utils.h is included before any GL headers.
#include "gpu/command_buffer/service/gl_utils.h"

#include "base/scoped_ptr.h"
#include "gfx/gl/gl_context.h"
#include "gfx/gl/gl_context_osmesa.h"
#include "gpu/command_buffer/service/gl_context.h"
#include "gpu/command_buffer/service/gl_context_osmesa.h"
#include "gpu/command_buffer/common/logging.h"

namespace gfx {
namespace gpu {

typedef HGLRC GLContextHandle;
typedef HPBUFFERARB PbufferHandle;
Expand Down Expand Up @@ -622,4 +620,4 @@ GLContext* GLContext::CreateOffscreenGLContext(void* shared_handle) {
}
}

} // namespace gfx
} // namespace gpu
14 changes: 7 additions & 7 deletions gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#include "base/weak_ptr.h"
#include "build/build_config.h"
#define GLES2_GPU_SERVICE 1
#include "gfx/gl/gl_context.h"
#include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/buffer_manager.h"
#include "gpu/command_buffer/service/cmd_buffer_engine.h"
#include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/framebuffer_manager.h"
#include "gpu/command_buffer/service/gl_context.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/command_buffer/service/id_manager.h"
Expand Down Expand Up @@ -368,7 +368,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
virtual const char* GetCommandName(unsigned int command_id) const;

// Overridden from GLES2Decoder.
virtual bool Initialize(gfx::GLContext* context,
virtual bool Initialize(GLContext* context,
const gfx::Size& size,
GLES2Decoder* parent,
uint32 parent_client_texture_id);
Expand All @@ -377,7 +377,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
virtual bool MakeCurrent();
virtual uint32 GetServiceIdForTesting(uint32 client_id);
virtual GLES2Util* GetGLES2Util() { return &util_; }
virtual gfx::GLContext* GetGLContext() { return context_; }
virtual GLContext* GetGLContext() { return context_; }

virtual void SetSwapBuffersCallback(Callback0::Type* callback);

Expand Down Expand Up @@ -827,14 +827,14 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
#undef GLES2_CMD_OP

// The GL context this decoder renders to on behalf of the client.
gfx::GLContext* context_;
GLContext* context_;

// A GLContext that is kept in its default state. It is used to perform
// operations that should not be dependent on client set GLContext state, like
// clearing a render buffer when it is created.
// TODO(apatrick): Decoders in the same ContextGroup could potentially share
// the same default GL context.
scoped_ptr<gfx::GLContext> default_context_;
scoped_ptr<GLContext> default_context_;

// A parent decoder can access this decoders saved offscreen frame buffer.
// The parent pointer is reset if the parent is destroyed.
Expand Down Expand Up @@ -1168,7 +1168,7 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
anti_aliased_(false) {
}

bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
bool GLES2DecoderImpl::Initialize(GLContext* context,
const gfx::Size& size,
GLES2Decoder* parent,
uint32 parent_client_texture_id) {
Expand All @@ -1178,7 +1178,7 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,

// Create a GL context that is kept in a default state and shares a namespace
// with the main GL context.
default_context_.reset(gfx::GLContext::CreateOffscreenGLContext(
default_context_.reset(GLContext::CreateOffscreenGLContext(
context_->GetHandle()));
if (!default_context_.get()) {
Destroy();
Expand Down
10 changes: 5 additions & 5 deletions gpu/command_buffer/service/gles2_cmd_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include "gfx/size.h"
#include "gpu/command_buffer/service/common_decoder.h"

namespace gfx {
class GLContext;
}

namespace gpu {
// Forward-declared instead of including gl_context.h, because including glx.h
// causes havok.
class GLContext;

namespace gles2 {

Expand Down Expand Up @@ -53,7 +53,7 @@ class GLES2Decoder : public CommonDecoder {
// parent's namespace.
// Returns:
// true if successful.
virtual bool Initialize(gfx::GLContext* context,
virtual bool Initialize(GLContext* context,
const gfx::Size& size,
GLES2Decoder* parent,
uint32 parent_client_texture_id) = 0;
Expand All @@ -74,7 +74,7 @@ class GLES2Decoder : public CommonDecoder {
virtual GLES2Util* GetGLES2Util() = 0;

// Gets the associated GLContext.
virtual gfx::GLContext* GetGLContext() = 0;
virtual GLContext* GetGLContext() = 0;

// Sets a callback which is called when a SwapBuffers command is processed.
virtual void SetSwapBuffersCallback(Callback0::Type* callback) = 0;
Expand Down
Loading

0 comments on commit 96f8063

Please sign in to comment.