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

Side by Side Diff: ui/gl/gl_surface_ozone.cc

Issue 1258713002: ozone: unify GpuMemoryBufferFactoryOzoneNativePixmap in content/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix linux_chromium_gn_dgb build Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « ui/gl/gl_image_ozone_native_pixmap.cc ('k') | ui/ozone/demo/ozone_demo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gl/gl_surface.h" 5 #include "ui/gl/gl_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/worker_pool.h" 14 #include "base/threading/worker_pool.h"
15 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gl/gl_context.h" 16 #include "ui/gl/gl_context.h"
17 #include "ui/gl/gl_image.h" 17 #include "ui/gl/gl_image.h"
18 #include "ui/gl/gl_image_linux_dma_buffer.h" 18 #include "ui/gl/gl_image_ozone_native_pixmap.h"
19 #include "ui/gl/gl_implementation.h" 19 #include "ui/gl/gl_implementation.h"
20 #include "ui/gl/gl_surface_egl.h" 20 #include "ui/gl/gl_surface_egl.h"
21 #include "ui/gl/gl_surface_osmesa.h" 21 #include "ui/gl/gl_surface_osmesa.h"
22 #include "ui/gl/gl_surface_stub.h" 22 #include "ui/gl/gl_surface_stub.h"
23 #include "ui/gl/scoped_binders.h" 23 #include "ui/gl/scoped_binders.h"
24 #include "ui/gl/scoped_make_current.h" 24 #include "ui/gl/scoped_make_current.h"
25 #include "ui/ozone/public/native_pixmap.h" 25 #include "ui/ozone/public/native_pixmap.h"
26 #include "ui/ozone/public/ozone_platform.h" 26 #include "ui/ozone/public/ozone_platform.h"
27 #include "ui/ozone/public/surface_factory_ozone.h" 27 #include "ui/ozone/public/surface_factory_ozone.h"
28 #include "ui/ozone/public/surface_ozone_egl.h" 28 #include "ui/ozone/public/surface_ozone_egl.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // GLSurface: 421 // GLSurface:
422 unsigned int GetBackingFrameBufferObject() override; 422 unsigned int GetBackingFrameBufferObject() override;
423 bool OnMakeCurrent(GLContext* context) override; 423 bool OnMakeCurrent(GLContext* context) override;
424 bool Resize(const gfx::Size& size) override; 424 bool Resize(const gfx::Size& size) override;
425 bool SupportsPostSubBuffer() override; 425 bool SupportsPostSubBuffer() override;
426 gfx::SwapResult SwapBuffers() override; 426 gfx::SwapResult SwapBuffers() override;
427 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; 427 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override;
428 void Destroy() override; 428 void Destroy() override;
429 429
430 private: 430 private:
431 class SurfaceImage : public GLImageLinuxDMABuffer {
432 public:
433 SurfaceImage(const gfx::Size& size, unsigned internalformat);
434
435 bool Initialize(scoped_refptr<ui::NativePixmap> pixmap,
436 gfx::GpuMemoryBuffer::Format format);
437 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
438 int z_order,
439 gfx::OverlayTransform transform,
440 const gfx::Rect& bounds_rect,
441 const gfx::RectF& crop_rect) override;
442
443 private:
444 ~SurfaceImage() override;
445
446 scoped_refptr<ui::NativePixmap> pixmap_;
447 };
448
449 ~GLSurfaceOzoneSurfacelessSurfaceImpl() override; 431 ~GLSurfaceOzoneSurfacelessSurfaceImpl() override;
450 432
451 void BindFramebuffer(); 433 void BindFramebuffer();
452 bool CreatePixmaps(); 434 bool CreatePixmaps();
453 435
454 GLuint fbo_; 436 GLuint fbo_;
455 GLuint textures_[2]; 437 GLuint textures_[2];
456 scoped_refptr<GLImage> images_[2]; 438 scoped_refptr<GLImage> images_[2];
457 int current_surface_; 439 int current_surface_;
458 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfacelessSurfaceImpl); 440 DISALLOW_COPY_AND_ASSIGN(GLSurfaceOzoneSurfacelessSurfaceImpl);
459 }; 441 };
460 442
461 GLSurfaceOzoneSurfacelessSurfaceImpl::SurfaceImage::SurfaceImage(
462 const gfx::Size& size,
463 unsigned internalformat)
464 : GLImageLinuxDMABuffer(size, internalformat) {
465 }
466
467 bool GLSurfaceOzoneSurfacelessSurfaceImpl::SurfaceImage::Initialize(
468 scoped_refptr<ui::NativePixmap> pixmap,
469 gfx::GpuMemoryBuffer::Format format) {
470 base::FileDescriptor handle(pixmap->GetDmaBufFd(), false);
471 if (!GLImageLinuxDMABuffer::Initialize(handle, format,
472 pixmap->GetDmaBufPitch()))
473 return false;
474 pixmap_ = pixmap;
475 return true;
476 }
477 bool GLSurfaceOzoneSurfacelessSurfaceImpl::SurfaceImage::ScheduleOverlayPlane(
478 gfx::AcceleratedWidget widget,
479 int z_order,
480 gfx::OverlayTransform transform,
481 const gfx::Rect& bounds_rect,
482 const gfx::RectF& crop_rect) {
483 return pixmap_->ScheduleOverlayPlane(widget, z_order, transform, bounds_rect,
484 crop_rect);
485 }
486
487 GLSurfaceOzoneSurfacelessSurfaceImpl::SurfaceImage::~SurfaceImage() {
488 }
489
490 GLSurfaceOzoneSurfacelessSurfaceImpl::GLSurfaceOzoneSurfacelessSurfaceImpl( 443 GLSurfaceOzoneSurfacelessSurfaceImpl::GLSurfaceOzoneSurfacelessSurfaceImpl(
491 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface, 444 scoped_ptr<ui::SurfaceOzoneEGL> ozone_surface,
492 AcceleratedWidget widget) 445 AcceleratedWidget widget)
493 : GLSurfaceOzoneSurfaceless(ozone_surface.Pass(), widget), 446 : GLSurfaceOzoneSurfaceless(ozone_surface.Pass(), widget),
494 fbo_(0), 447 fbo_(0),
495 current_surface_(0) { 448 current_surface_(0) {
496 for (auto& texture : textures_) 449 for (auto& texture : textures_)
497 texture = 0; 450 texture = 0;
498 } 451 }
499 452
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 return true; 539 return true;
587 for (size_t i = 0; i < arraysize(textures_); i++) { 540 for (size_t i = 0; i < arraysize(textures_); i++) {
588 scoped_refptr<ui::NativePixmap> pixmap = 541 scoped_refptr<ui::NativePixmap> pixmap =
589 ui::OzonePlatform::GetInstance() 542 ui::OzonePlatform::GetInstance()
590 ->GetSurfaceFactoryOzone() 543 ->GetSurfaceFactoryOzone()
591 ->CreateNativePixmap(widget_, GetSize(), 544 ->CreateNativePixmap(widget_, GetSize(),
592 ui::SurfaceFactoryOzone::BGRA_8888, 545 ui::SurfaceFactoryOzone::BGRA_8888,
593 ui::SurfaceFactoryOzone::SCANOUT); 546 ui::SurfaceFactoryOzone::SCANOUT);
594 if (!pixmap) 547 if (!pixmap)
595 return false; 548 return false;
596 scoped_refptr<SurfaceImage> image = 549 scoped_refptr<GLImageOzoneNativePixmap> image =
597 new SurfaceImage(GetSize(), GL_BGRA_EXT); 550 new GLImageOzoneNativePixmap(GetSize(), GL_BGRA_EXT);
598 if (!image->Initialize(pixmap, gfx::GpuMemoryBuffer::Format::BGRA_8888)) 551 if (!image->Initialize(pixmap.get(),
552 gfx::GpuMemoryBuffer::Format::BGRA_8888))
599 return false; 553 return false;
600 images_[i] = image; 554 images_[i] = image;
601 // Bind image to texture. 555 // Bind image to texture.
602 ScopedTextureBinder binder(GL_TEXTURE_2D, textures_[i]); 556 ScopedTextureBinder binder(GL_TEXTURE_2D, textures_[i]);
603 if (!images_[i]->BindTexImage(GL_TEXTURE_2D)) 557 if (!images_[i]->BindTexImage(GL_TEXTURE_2D))
604 return false; 558 return false;
605 } 559 }
606 return true; 560 return true;
607 } 561 }
608 562
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 } 681 }
728 } 682 }
729 683
730 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() { 684 EGLNativeDisplayType GetPlatformDefaultEGLNativeDisplay() {
731 return ui::OzonePlatform::GetInstance() 685 return ui::OzonePlatform::GetInstance()
732 ->GetSurfaceFactoryOzone() 686 ->GetSurfaceFactoryOzone()
733 ->GetNativeDisplay(); 687 ->GetNativeDisplay();
734 } 688 }
735 689
736 } // namespace gfx 690 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_image_ozone_native_pixmap.cc ('k') | ui/ozone/demo/ozone_demo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698