Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" | 5 #include "ui/ozone/platform/drm/gpu/gbm_surface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/display/types/display_snapshot.h" | |
| 10 #include "ui/gfx/native_pixmap.h" | 11 #include "ui/gfx/native_pixmap.h" |
| 11 #include "ui/gl/gl_image_native_pixmap.h" | 12 #include "ui/gl/gl_image_native_pixmap.h" |
| 12 #include "ui/gl/gl_surface_egl.h" | 13 #include "ui/gl/gl_surface_egl.h" |
| 13 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" | 14 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" |
| 14 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" | 15 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h" |
| 15 | 16 |
| 16 namespace ui { | 17 namespace ui { |
| 17 | 18 |
| 18 GbmSurface::GbmSurface(GbmSurfaceFactory* surface_factory, | 19 GbmSurface::GbmSurface(GbmSurfaceFactory* surface_factory, |
| 19 std::unique_ptr<DrmWindowProxy> window, | 20 std::unique_ptr<DrmWindowProxy> window, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 gl::ScopedFramebufferBinder fb(fbo_); | 117 gl::ScopedFramebufferBinder fb(fbo_); |
| 117 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 118 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 118 textures_[current_surface_], 0); | 119 textures_[current_surface_], 0); |
| 119 } | 120 } |
| 120 | 121 |
| 121 bool GbmSurface::CreatePixmaps() { | 122 bool GbmSurface::CreatePixmaps() { |
| 122 if (!fbo_) | 123 if (!fbo_) |
| 123 return true; | 124 return true; |
| 124 for (size_t i = 0; i < arraysize(textures_); i++) { | 125 for (size_t i = 0; i < arraysize(textures_); i++) { |
| 125 scoped_refptr<gfx::NativePixmap> pixmap = | 126 scoped_refptr<gfx::NativePixmap> pixmap = |
| 126 surface_factory()->CreateNativePixmap(widget(), GetSize(), | 127 surface_factory()->CreateNativePixmap( |
| 127 gfx::BufferFormat::BGRA_8888, | 128 widget(), GetSize(), display::DisplaySnapshot::PrimaryFormat(), |
| 128 gfx::BufferUsage::SCANOUT); | 129 gfx::BufferUsage::SCANOUT); |
| 129 if (!pixmap) | 130 if (!pixmap) |
| 130 return false; | 131 return false; |
| 131 scoped_refptr<gl::GLImageNativePixmap> image = | 132 scoped_refptr<gl::GLImageNativePixmap> image = |
| 132 new gl::GLImageNativePixmap(GetSize(), GL_BGRA_EXT); | 133 new gl::GLImageNativePixmap(GetSize(), GL_RGB); |
|
dnicoara
2017/04/19 14:31:09
Why is this GL_RGB? Wouldn't this mean a pixel wit
Daniele Castagna
2017/04/19 14:51:06
That's the internal pixel format, it doesn't need
dnicoara
2017/04/19 15:08:23
Yeah, I saw that and it also confused me. So, what
| |
| 133 if (!image->Initialize(pixmap.get(), gfx::BufferFormat::BGRA_8888)) | 134 if (!image->Initialize(pixmap.get(), |
| 135 display::DisplaySnapshot::PrimaryFormat())) | |
| 134 return false; | 136 return false; |
| 135 images_[i] = image; | 137 images_[i] = image; |
| 136 // Bind image to texture. | 138 // Bind image to texture. |
| 137 gl::ScopedTextureBinder binder(GL_TEXTURE_2D, textures_[i]); | 139 gl::ScopedTextureBinder binder(GL_TEXTURE_2D, textures_[i]); |
| 138 if (!images_[i]->BindTexImage(GL_TEXTURE_2D)) | 140 if (!images_[i]->BindTexImage(GL_TEXTURE_2D)) |
| 139 return false; | 141 return false; |
| 140 } | 142 } |
| 141 return true; | 143 return true; |
| 142 } | 144 } |
| 143 | 145 |
| 144 } // namespace ui | 146 } // namespace ui |
| OLD | NEW |