Skip to content

Commit

Permalink
[//gpu] Restrict creation of GLImageNativePixmap
Browse files Browse the repository at this point in the history
As we are in the process of eliminating this class, this CL makes its
interface private and friends existing callers of
GLImageNativePixmap::Create().

Bug: 1310018
Change-Id: Ib81fc655c22f87a95d5db6c503432026d1b8afff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4272248
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Reviewed-by: Robert Kroeger <rjkroege@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1109498}
  • Loading branch information
colinblundell authored and Chromium LUCI CQ committed Feb 24, 2023
1 parent 53c1914 commit aafd2b9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 29 additions & 2 deletions gpu/command_buffer/service/shared_image/gl_image_native_pixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,54 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image.h"

namespace media {
class GenericV4L2Device;
class VaapiPictureNativePixmapOzone;
} // namespace media

namespace ui {
class NativePixmapGLBinding;
}

namespace gpu {

namespace gles2 {
class GLES2DecoderImpl;
}

class GPU_GLES2_EXPORT GLImageNativePixmap : public gl::GLImage {
public:
private:
// Create an EGLImage from a given NativePixmap and bind |texture_id| to
// |target| following by binding the image to |target|.
// NOTE: As we are in the process of eliminating this class, there should be
// no new usages of it introduced.
static scoped_refptr<GLImageNativePixmap> Create(
const gfx::Size& size,
gfx::BufferFormat format,
scoped_refptr<gfx::NativePixmap> pixmap,
GLenum target,
GLuint texture_id);

public:
// Wrapper to allow for creation in testing contexts that are difficult to
// friend.
static scoped_refptr<GLImageNativePixmap> CreateForTesting(
const gfx::Size& size,
gfx::BufferFormat format,
scoped_refptr<gfx::NativePixmap> pixmap,
GLenum target,
GLuint texture_id) {
return Create(size, format, pixmap, target, texture_id);
}

private:
friend class gles2::GLES2DecoderImpl;
friend class media::GenericV4L2Device;
friend class media::VaapiPictureNativePixmapOzone;

// Overridden from GLImage:
gfx::Size GetSize() override;

private:
explicit GLImageNativePixmap(const gfx::Size& size);
~GLImageNativePixmap() override;

Expand Down
2 changes: 1 addition & 1 deletion ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GLImageNativePixmapTestDelegate : public GLImageTestDelegateBase {
glGenTextures(1, &texture_id_);
}

auto image = gpu::GLImageNativePixmap::Create(
auto image = gpu::GLImageNativePixmap::CreateForTesting(
size, format, std::move(pixmap), GetTextureTarget(), texture_id_);
EXPECT_TRUE(image);
return image;
Expand Down

0 comments on commit aafd2b9

Please sign in to comment.