diff options
author | achaulk@chromium.org <achaulk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 17:19:10 +0000 |
---|---|---|
committer | achaulk@chromium.org <achaulk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 17:19:10 +0000 |
commit | d286ebbcc2ded63632b90971d3fe0193ff058434 (patch) | |
tree | a47f5cae0716f19acdc641a182859a8ae8884b8a | |
parent | aeecc6b28ffd9c0f6183c1c2b818a0a2cd9e7d40 (diff) | |
download | chromium_src-d286ebbcc2ded63632b90971d3fe0193ff058434.zip chromium_src-d286ebbcc2ded63632b90971d3fe0193ff058434.tar.gz chromium_src-d286ebbcc2ded63632b90971d3fe0193ff058434.tar.bz2 |
Implement ScheduleOverlayPlaneCHROMIUM via GLSurface.
BUG=380861
Review URL: https://codereview.chromium.org/369593002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281284 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 55 | ||||
-rw-r--r-- | ui/gl/gl_bindings.h | 8 | ||||
-rw-r--r-- | ui/gl/gl_surface.cc | 18 | ||||
-rw-r--r-- | ui/gl/gl_surface.h | 25 |
4 files changed, 102 insertions, 4 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index a1a0e40..0c04999 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -153,6 +153,25 @@ static void GetShaderPrecisionFormatImpl(GLenum shader_type, } } +static gfx::OverlayTransform GetGFXOverlayTransform(GLenum plane_transform) { + switch (plane_transform) { + case GL_OVERLAY_TRANSFORM_NONE_CHROMIUM: + return gfx::OVERLAY_TRANSFORM_NONE; + case GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM: + return gfx::OVERLAY_TRANSFORM_FLIP_HORIZONTAL; + case GL_OVERLAY_TRANSFORM_FLIP_VERTICAL_CHROMIUM: + return gfx::OVERLAY_TRANSFORM_FLIP_VERTICAL; + case GL_OVERLAY_TRANSFORM_ROTATE_90_CHROMIUM: + return gfx::OVERLAY_TRANSFORM_ROTATE_90; + case GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM: + return gfx::OVERLAY_TRANSFORM_ROTATE_180; + case GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM: + return gfx::OVERLAY_TRANSFORM_ROTATE_270; + default: + return gfx::OVERLAY_TRANSFORM_INVALID; + } +} + } // namespace class GLES2DecoderImpl; @@ -7585,10 +7604,38 @@ error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( error::Error GLES2DecoderImpl::HandleScheduleOverlayPlaneCHROMIUM( uint32 immediate_data_size, const cmds::ScheduleOverlayPlaneCHROMIUM& c) { - NOTIMPLEMENTED() << "Overlay supported isn't finished."; - LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, - "glScheduleOverlayPlaneCHROMIUM", - "function not implemented"); + TextureRef* ref = texture_manager()->GetTexture(c.overlay_texture_id); + if (!ref) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, + "glScheduleOverlayPlaneCHROMIUM", + "unknown texture"); + return error::kNoError; + } + gfx::GLImage* image = + ref->texture()->GetLevelImage(ref->texture()->target(), 0); + if (!image) { + LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, + "glScheduleOverlayPlaneCHROMIUM", + "unsupported texture format"); + return error::kNoError; + } + gfx::OverlayTransform transform = GetGFXOverlayTransform(c.plane_transform); + if (transform == gfx::OVERLAY_TRANSFORM_INVALID) { + LOCAL_SET_GL_ERROR(GL_INVALID_ENUM, + "glScheduleOverlayPlaneCHROMIUM", + "invalid transform enum"); + return error::kNoError; + } + if (!surface_->ScheduleOverlayPlane( + c.plane_z_order, + transform, + image, + gfx::Rect(c.bounds_x, c.bounds_y, c.bounds_width, c.bounds_height), + gfx::RectF(c.uv_x, c.uv_y, c.uv_width, c.uv_height))) { + LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, + "glScheduleOverlayPlaneCHROMIUM", + "failed to schedule overlay"); + } return error::kNoError; } diff --git a/ui/gl/gl_bindings.h b/ui/gl/gl_bindings.h index 23182bc..f763761 100644 --- a/ui/gl/gl_bindings.h +++ b/ui/gl/gl_bindings.h @@ -136,6 +136,14 @@ #define GL_IMAGE_MAP_CHROMIUM 0x78F1 #define GL_IMAGE_SCANOUT_CHROMIUM 0x78F2 +// GL_CHROMIUM_schedule_overlay_plane +#define GL_OVERLAY_TRANSFORM_NONE_CHROMIUM 0x9245 +#define GL_OVERLAY_TRANSFORM_FLIP_HORIZONTAL_CHROMIUM 0x9246 +#define GL_OVERLAY_TRANSFORM_FLIP_VERTICAL_CHROMIUM 0x9247 +#define GL_OVERLAY_TRANSFORM_ROTATE_90_CHROMIUM 0x9248 +#define GL_OVERLAY_TRANSFORM_ROTATE_180_CHROMIUM 0x9249 +#define GL_OVERLAY_TRANSFORM_ROTATE_270_CHROMIUM 0x924A + // GL_OES_texure_3D #define GL_SAMPLER_3D_OES 0x8B5F diff --git a/ui/gl/gl_surface.cc b/ui/gl/gl_surface.cc index 92b2b45..31b5ab9 100644 --- a/ui/gl/gl_surface.cc +++ b/ui/gl/gl_surface.cc @@ -226,6 +226,15 @@ VSyncProvider* GLSurface::GetVSyncProvider() { return NULL; } +bool GLSurface::ScheduleOverlayPlane(int z_order, + OverlayTransform transform, + GLImage* image, + const Rect& bounds_rect, + const RectF& crop_rect) { + NOTIMPLEMENTED(); + return false; +} + GLSurface* GLSurface::GetCurrent() { return current_surface_.Pointer()->Get(); } @@ -334,6 +343,15 @@ VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { return surface_->GetVSyncProvider(); } +bool GLSurfaceAdapter::ScheduleOverlayPlane(int z_order, + OverlayTransform transform, + GLImage* image, + const Rect& bounds_rect, + const RectF& crop_rect) { + return surface_->ScheduleOverlayPlane( + z_order, transform, image, bounds_rect, crop_rect); +} + GLSurfaceAdapter::~GLSurfaceAdapter() {} } // namespace gfx diff --git a/ui/gl/gl_surface.h b/ui/gl/gl_surface.h index 70336ba..ed029ad 100644 --- a/ui/gl/gl_surface.h +++ b/ui/gl/gl_surface.h @@ -10,6 +10,9 @@ #include "base/memory/ref_counted.h" #include "build/build_config.h" #include "ui/gfx/native_widget_types.h" +#include "ui/gfx/overlay_transform.h" +#include "ui/gfx/rect.h" +#include "ui/gfx/rect_f.h" #include "ui/gfx/size.h" #include "ui/gl/gl_export.h" #include "ui/gl/gl_implementation.h" @@ -17,6 +20,7 @@ namespace gfx { class GLContext; +class GLImage; class VSyncProvider; // Encapsulates a surface that can be rendered to with GL, hiding platform @@ -102,6 +106,22 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { // of screen refresh. If unavailable, returns NULL. virtual VSyncProvider* GetVSyncProvider(); + // Schedule an overlay plane to be shown at swap time. + // |z_order| specifies the stacking order of the plane relative to the + // main framebuffer located at index 0. For the case where there is no + // main framebuffer, overlays may be scheduled at 0, taking its place. + // |transform| specifies how the buffer is to be transformed during + // composition. + // |image| to be presented by the overlay. + // |bounds_rect| specify where it is supposed to be on the screen in pixels. + // |crop_rect| specifies the region within the buffer to be placed inside + // |bounds_rect|. + virtual bool ScheduleOverlayPlane(int z_order, + OverlayTransform transform, + GLImage* image, + const Rect& bounds_rect, + const RectF& crop_rect); + // Create a GL surface that renders directly to a view. static scoped_refptr<GLSurface> CreateViewGLSurface( gfx::AcceleratedWidget window); @@ -156,6 +176,11 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface { virtual void* GetConfig() OVERRIDE; virtual unsigned GetFormat() OVERRIDE; virtual VSyncProvider* GetVSyncProvider() OVERRIDE; + virtual bool ScheduleOverlayPlane(int z_order, + OverlayTransform transform, + GLImage* image, + const Rect& bounds_rect, + const RectF& crop_rect) OVERRIDE; GLSurface* surface() const { return surface_.get(); } |