Commit fa4afa9c authored by reveman's avatar reveman Committed by Commit bot

ui: Remove GLImageGLX.

This code is not being shipped and there are no plans that will
change that. Remove it for now as it means less code to maintain
and will allow some cleanup. It can be added back later if needed.

BUG=
R=piman@chromium.org

Review URL: https://codereview.chromium.org/699643002

Cr-Commit-Position: refs/heads/master@{#302470}
parent fdb176eb
......@@ -179,10 +179,6 @@ source_set("common") {
}
if (use_x11) {
sources += [
"gpu/gpu_memory_buffer_factory_x11_pixmap.cc",
"common/gpu/gpu_memory_buffer_factory_x11_pixmap.h",
]
include_dirs += [ "//third_party/khronos" ]
configs += [ "//build/config/linux:xcomposite" ]
......@@ -192,10 +188,6 @@ source_set("common") {
"gpu/x_util.h",
]
}
} else {
sources -= [
"gpu/gpu_memory_buffer_factory_x11.cc",
]
}
if (enable_plugins) {
......
......@@ -5,7 +5,6 @@
#include "content/common/gpu/gpu_memory_buffer_factory.h"
#include "base/logging.h"
#include "content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h"
#include "gpu/command_buffer/service/image_factory.h"
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_image_shared_memory.h"
......@@ -22,30 +21,16 @@ class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory,
const gfx::Size& size,
gfx::GpuMemoryBuffer::Format format,
gfx::GpuMemoryBuffer::Usage usage) override {
switch (handle.type) {
case gfx::X11_PIXMAP_BUFFER:
x11_pixmap_factory_.CreateGpuMemoryBuffer(handle.global_id,
handle.pixmap);
return handle;
default:
NOTREACHED();
return gfx::GpuMemoryBufferHandle();
}
}
void DestroyGpuMemoryBuffer(
const gfx::GpuMemoryBufferHandle& handle) override {
switch (handle.type) {
case gfx::X11_PIXMAP_BUFFER:
x11_pixmap_factory_.DestroyGpuMemoryBuffer(handle.global_id);
break;
default:
NOTREACHED();
break;
}
}
gpu::ImageFactory* AsImageFactory() override { return this; }
// Overridden from gpu::GpuMemoryBufferFactory:
// Overridden from gpu::ImageFactory:
scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
const gfx::GpuMemoryBufferHandle& handle,
const gfx::Size& size,
......@@ -61,21 +46,11 @@ class GpuMemoryBufferFactoryImpl : public GpuMemoryBufferFactory,
return image;
}
case gfx::X11_PIXMAP_BUFFER:
// Verify that client is the owner of the buffer we're about to use.
if (handle.global_id.secondary_id != client_id)
return scoped_refptr<gfx::GLImage>();
return x11_pixmap_factory_.CreateImageForGpuMemoryBuffer(
handle.global_id, size, internalformat);
default:
NOTREACHED();
return scoped_refptr<gfx::GLImage>();
}
}
private:
GpuMemoryBufferFactoryX11Pixmap x11_pixmap_factory_;
};
} // namespace
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/common/gpu/gpu_memory_buffer_factory_x11_pixmap.h"
#include "ui/gl/gl_image_glx.h"
namespace content {
GpuMemoryBufferFactoryX11Pixmap::GpuMemoryBufferFactoryX11Pixmap() {
}
GpuMemoryBufferFactoryX11Pixmap::~GpuMemoryBufferFactoryX11Pixmap() {
}
void GpuMemoryBufferFactoryX11Pixmap::CreateGpuMemoryBuffer(
const gfx::GpuMemoryBufferId& id,
XID pixmap) {
X11PixmapMapKey key(id.primary_id, id.secondary_id);
DCHECK(pixmaps_.find(key) == pixmaps_.end());
pixmaps_[key] = pixmap;
}
void GpuMemoryBufferFactoryX11Pixmap::DestroyGpuMemoryBuffer(
const gfx::GpuMemoryBufferId& id) {
X11PixmapMapKey key(id.primary_id, id.secondary_id);
X11PixmapMap::iterator it = pixmaps_.find(key);
if (it != pixmaps_.end())
pixmaps_.erase(it);
}
scoped_refptr<gfx::GLImage>
GpuMemoryBufferFactoryX11Pixmap::CreateImageForGpuMemoryBuffer(
const gfx::GpuMemoryBufferId& id,
const gfx::Size& size,
unsigned internalformat) {
X11PixmapMapKey key(id.primary_id, id.secondary_id);
X11PixmapMap::iterator it = pixmaps_.find(key);
if (it == pixmaps_.end())
return scoped_refptr<gfx::GLImage>();
scoped_refptr<gfx::GLImageGLX> image(
new gfx::GLImageGLX(size, internalformat));
if (!image->Initialize(it->second))
return scoped_refptr<gfx::GLImage>();
return image;
}
} // namespace content
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_X11_PIXMAP_H_
#define CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_X11_PIXMAP_H_
#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gfx/x/x11_types.h"
namespace gfx {
class GLImage;
}
namespace content {
class GpuMemoryBufferFactoryX11Pixmap {
public:
GpuMemoryBufferFactoryX11Pixmap();
~GpuMemoryBufferFactoryX11Pixmap();
// Create a GPU memory buffer for an existing X11 pixmap.
void CreateGpuMemoryBuffer(const gfx::GpuMemoryBufferId& id, XID pixmap);
// Destroy a previously created GPU memory buffer.
void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferId& id);
// Creates a GLImage instance for a GPU memory buffer.
scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
const gfx::GpuMemoryBufferId& id,
const gfx::Size& size,
unsigned internalformat);
private:
typedef std::pair<int, int> X11PixmapMapKey;
typedef base::hash_map<X11PixmapMapKey, XID> X11PixmapMap;
X11PixmapMap pixmaps_;
};
} // namespace content
#endif // CONTENT_COMMON_GPU_GPU_MEMORY_BUFFER_FACTORY_X11_PIXMAP_H_
......@@ -287,10 +287,10 @@
'common/gpu/gpu_config.h',
'common/gpu/gpu_memory_buffer_factory.h',
'common/gpu/gpu_memory_buffer_factory_android.cc',
'common/gpu/gpu_memory_buffer_factory_linux.cc',
'common/gpu/gpu_memory_buffer_factory_mac.cc',
'common/gpu/gpu_memory_buffer_factory_ozone.cc',
'common/gpu/gpu_memory_buffer_factory_win.cc',
'common/gpu/gpu_memory_buffer_factory_x11.cc',
'common/gpu/gpu_memory_manager.cc',
'common/gpu/gpu_memory_manager.h',
'common/gpu/gpu_memory_manager_client.cc',
......@@ -695,10 +695,6 @@
'dependencies': [
'<(DEPTH)/build/linux/system.gyp:xcomposite',
],
'sources': [
'common/gpu/gpu_memory_buffer_factory_x11_pixmap.cc',
'common/gpu/gpu_memory_buffer_factory_x11_pixmap.h',
],
}],
['use_x11 == 1 and (target_arch != "arm" or chromeos == 0)', {
'sources': [
......
......@@ -163,8 +163,6 @@ component("gl") {
"gl_context_x11.cc",
"gl_glx_api_implementation.cc",
"gl_glx_api_implementation.h",
"gl_image_glx.cc",
"gl_image_glx.h",
"gl_implementation_x11.cc",
"gl_surface_glx.cc",
"gl_surface_glx.h",
......
......@@ -210,8 +210,6 @@
'gl_context_glx.h',
'gl_glx_api_implementation.cc',
'gl_glx_api_implementation.h',
'gl_image_glx.cc',
'gl_image_glx.h',
'gl_surface_glx.cc',
'gl_surface_glx.h',
'gl_egl_api_implementation.cc',
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern "C" {
#include <X11/Xlib.h>
}
#include "ui/gl/gl_image_glx.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_glx.h"
namespace gfx {
namespace {
// scoped_ptr functor for XFree(). Use as follows:
// scoped_ptr<XVisualInfo, ScopedPtrXFree> foo(...);
// where "XVisualInfo" is any X type that is freed with XFree.
struct ScopedPtrXFree {
void operator()(void* x) const { ::XFree(x); }
};
bool ValidFormat(unsigned internalformat) {
switch (internalformat) {
case GL_RGBA:
return true;
default:
return false;
}
}
int TextureFormat(unsigned internalformat) {
switch (internalformat) {
case GL_RGBA:
return GLX_TEXTURE_FORMAT_RGBA_EXT;
default:
NOTREACHED();
return 0;
}
}
int BindToTextureFormat(unsigned internalformat) {
switch (internalformat) {
case GL_RGBA:
return GLX_BIND_TO_TEXTURE_RGBA_EXT;
default:
NOTREACHED();
return 0;
}
}
unsigned PixmapDepth(unsigned internalformat) {
switch (internalformat) {
case GL_RGBA:
return 32u;
default:
NOTREACHED();
return 0u;
}
}
bool ActualPixmapGeometry(XID pixmap, gfx::Size* size, unsigned* depth) {
XID root_return;
int x_return;
int y_return;
unsigned width_return;
unsigned height_return;
unsigned border_width_return;
unsigned depth_return;
if (!XGetGeometry(gfx::GetXDisplay(),
pixmap,
&root_return,
&x_return,
&y_return,
&width_return,
&height_return,
&border_width_return,
&depth_return))
return false;
if (size)
*size = gfx::Size(width_return, height_return);
if (depth)
*depth = depth_return;
return true;
}
unsigned ActualPixmapDepth(XID pixmap) {
unsigned depth;
if (!ActualPixmapGeometry(pixmap, NULL, &depth))
return -1;
return depth;
}
gfx::Size ActualPixmapSize(XID pixmap) {
gfx::Size size;
if (!ActualPixmapGeometry(pixmap, &size, NULL))
return gfx::Size();
return size;
}
} // namespace anonymous
GLImageGLX::GLImageGLX(const gfx::Size& size, unsigned internalformat)
: glx_pixmap_(0), size_(size), internalformat_(internalformat) {
}
GLImageGLX::~GLImageGLX() {
DCHECK_EQ(0u, glx_pixmap_);
}
bool GLImageGLX::Initialize(XID pixmap) {
if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) {
DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported.";
return false;
}
if (!ValidFormat(internalformat_)) {
DVLOG(0) << "Invalid format: " << internalformat_;
return false;
}
DCHECK_EQ(PixmapDepth(internalformat_), ActualPixmapDepth(pixmap));
DCHECK_EQ(size_.ToString(), ActualPixmapSize(pixmap).ToString());
int config_attribs[] = {
GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_EXT,
BindToTextureFormat(internalformat_), GL_TRUE,
0};
int num_elements = 0;
scoped_ptr<GLXFBConfig, ScopedPtrXFree> config(
glXChooseFBConfig(gfx::GetXDisplay(),
DefaultScreen(gfx::GetXDisplay()),
config_attribs,
&num_elements));
if (!config.get()) {
DVLOG(0) << "glXChooseFBConfig failed.";
return false;
}
if (!num_elements) {
DVLOG(0) << "glXChooseFBConfig returned 0 elements.";
return false;
}
int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
GLX_TEXTURE_FORMAT_EXT,
TextureFormat(internalformat_), 0};
glx_pixmap_ = glXCreatePixmap(
gfx::GetXDisplay(), *config.get(), pixmap, pixmap_attribs);
if (!glx_pixmap_) {
DVLOG(0) << "glXCreatePixmap failed.";
return false;
}
return true;
}
void GLImageGLX::Destroy(bool have_context) {
if (glx_pixmap_) {
glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_);
glx_pixmap_ = 0;
}
}
gfx::Size GLImageGLX::GetSize() { return size_; }
bool GLImageGLX::BindTexImage(unsigned target) {
if (!glx_pixmap_)
return false;
// Requires TEXTURE_2D target.
if (target != GL_TEXTURE_2D)
return false;
glXBindTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT, 0);
return true;
}
void GLImageGLX::ReleaseTexImage(unsigned target) {
DCHECK_NE(0u, glx_pixmap_);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target);
glXReleaseTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT);
}
bool GLImageGLX::CopyTexImage(unsigned target) {
return false;
}
bool GLImageGLX::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
int z_order,
OverlayTransform transform,
const Rect& bounds_rect,
const RectF& crop_rect) {
return false;
}
} // namespace gfx
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GL_GL_IMAGE_GLX_H_
#define UI_GL_GL_IMAGE_GLX_H_
#include "ui/gfx/size.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_export.h"
#include "ui/gl/gl_image.h"
namespace gfx {
class GL_EXPORT GLImageGLX : public GLImage {
public:
GLImageGLX(const gfx::Size& size, unsigned internalformat);
bool Initialize(XID pixmap);
// Overridden from GLImage:
void Destroy(bool have_context) override;
gfx::Size GetSize() override;
bool BindTexImage(unsigned target) override;
void ReleaseTexImage(unsigned target) override;
bool CopyTexImage(unsigned target) override;
void WillUseTexImage() override {}
void DidUseTexImage() override {}
void WillModifyTexImage() override {}
void DidModifyTexImage() override {}
bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
int z_order,
OverlayTransform transform,
const Rect& bounds_rect,
const RectF& crop_rect) override;
protected:
~GLImageGLX() override;
private:
XID glx_pixmap_;
const gfx::Size size_;
unsigned internalformat_;
DISALLOW_COPY_AND_ASSIGN(GLImageGLX);
};
} // namespace gfx
#endif // UI_GL_GL_IMAGE_GLX_H_
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