Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: ui/ozone/demo/surfaceless_gl_renderer.cc

Issue 1258713002: ozone: unify GpuMemoryBufferFactoryOzoneNativePixmap in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resolve nits Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/demo/surfaceless_gl_renderer.cc
diff --git a/ui/ozone/demo/surfaceless_gl_renderer.cc b/ui/ozone/demo/surfaceless_gl_renderer.cc
index 0623285af36492a97ef39a5ef1df43ded2011ef2..0eaecb698175d398ac5b881a4d67f1af39c1d68e 100644
--- a/ui/ozone/demo/surfaceless_gl_renderer.cc
+++ b/ui/ozone/demo/surfaceless_gl_renderer.cc
@@ -8,8 +8,10 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_image.h"
+#include "ui/gl/gl_image_ozone_native_pixmap.h"
#include "ui/gl/gl_surface.h"
-#include "ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h"
+#include "ui/ozone/public/ozone_platform.h"
+#include "ui/ozone/public/surface_factory_ozone.h"
namespace ui {
@@ -28,28 +30,23 @@ SurfacelessGlRenderer::BufferWrapper::~BufferWrapper() {
}
bool SurfacelessGlRenderer::BufferWrapper::Initialize(
- GpuMemoryBufferFactoryOzoneNativePixmap* buffer_factory,
gfx::AcceleratedWidget widget,
const gfx::Size& size) {
glGenFramebuffersEXT(1, &gl_fb_);
glGenTextures(1, &gl_tex_);
- static int buffer_id_generator = 1;
- int id = buffer_id_generator++;
-
- buffer_factory->CreateGpuMemoryBuffer(
- id, size, gfx::GpuMemoryBuffer::RGBX_8888, gfx::GpuMemoryBuffer::SCANOUT,
- 1, widget);
- image_ = buffer_factory->CreateImageForGpuMemoryBuffer(
- id, size, gfx::GpuMemoryBuffer::RGBX_8888, GL_RGB, 1);
- // Now that we have a reference to |image_|; we can just remove it from the
- // factory mapping.
- buffer_factory->DestroyGpuMemoryBuffer(id, widget);
-
- if (!image_) {
- LOG(ERROR) << "Failed to create GL image";
+ scoped_refptr<NativePixmap> pixmap =
+ OzonePlatform::GetInstance()
+ ->GetSurfaceFactoryOzone()
+ ->CreateNativePixmap(widget, size, SurfaceFactoryOzone::RGBX_8888,
+ SurfaceFactoryOzone::SCANOUT);
+ scoped_refptr<gfx::GLImageOzoneNativePixmap> image(
+ new gfx::GLImageOzoneNativePixmap(size, GL_RGB));
+ if (!image->Initialize(pixmap.get(), gfx::GpuMemoryBuffer::RGBX_8888)) {
+ LOG(ERROR) << "Failed to create GLImage";
return false;
}
+ image_ = image;
glBindFramebufferEXT(GL_FRAMEBUFFER, gl_fb_);
glBindTexture(GL_TEXTURE_2D, gl_tex_);
@@ -78,13 +75,9 @@ void SurfacelessGlRenderer::BufferWrapper::SchedulePlane() {
gfx::Rect(size_), gfx::RectF(0, 0, 1, 1));
}
-SurfacelessGlRenderer::SurfacelessGlRenderer(
- gfx::AcceleratedWidget widget,
- const gfx::Size& size,
- GpuMemoryBufferFactoryOzoneNativePixmap* buffer_factory)
- : GlRenderer(widget, size),
- buffer_factory_(buffer_factory),
- weak_ptr_factory_(this) {}
+SurfacelessGlRenderer::SurfacelessGlRenderer(gfx::AcceleratedWidget widget,
+ const gfx::Size& size)
+ : GlRenderer(widget, size), weak_ptr_factory_(this) {}
SurfacelessGlRenderer::~SurfacelessGlRenderer() {
// Need to make current when deleting the framebuffer resources allocated in
@@ -97,7 +90,7 @@ bool SurfacelessGlRenderer::Initialize() {
return false;
for (size_t i = 0; i < arraysize(buffers_); ++i)
- if (!buffers_[i].Initialize(buffer_factory_, widget_, size_))
+ if (!buffers_[i].Initialize(widget_, size_))
return false;
PostRenderFrameTask(gfx::SwapResult::SWAP_ACK);

Powered by Google App Engine
This is Rietveld 408576698