Commit 3da8f19a authored by halliwell's avatar halliwell Committed by Commit bot

Adds public API and loads Cast OSD plane implementation from shared lib

BUG=

Review URL: https://codereview.chromium.org/1104853002

Cr-Commit-Position: refs/heads/master@{#327306}
parent df0e2666
...@@ -40,7 +40,11 @@ ...@@ -40,7 +40,11 @@
'public/cast_egl_platform_shlib.h', 'public/cast_egl_platform_shlib.h',
'public/cast_sys_info.h', 'public/cast_sys_info.h',
'public/chromecast_export.h', 'public/chromecast_export.h',
'public/graphics_properties_shlib.h' 'public/graphics_properties_shlib.h',
'public/graphics_types.h',
'public/osd_plane.h',
'public/osd_plane_shlib.h',
'public/osd_surface.h',
], ],
}, },
# TODO(gunsch): Remove this fake target once it's either added or no # TODO(gunsch): Remove this fake target once it's either added or no
...@@ -578,11 +582,7 @@ ...@@ -578,11 +582,7 @@
'media/media.gyp:cast_media', 'media/media.gyp:cast_media',
], ],
'conditions': [ 'conditions': [
['chromecast_branding=="Chrome"', { ['chromecast_branding!="Chrome"', {
'dependencies': [
'internal/chromecast_internal.gyp:cast_gfx_internal',
],
}, {
'dependencies': [ 'dependencies': [
'../ui/ozone/ozone.gyp:eglplatform_shim_x11', '../ui/ozone/ozone.gyp:eglplatform_shim_x11',
], ],
...@@ -621,7 +621,8 @@ ...@@ -621,7 +621,8 @@
], ],
'sources': [ 'sources': [
'graphics/cast_egl_platform_default.cc', 'graphics/cast_egl_platform_default.cc',
'graphics/graphics_properties_default.cc' 'graphics/graphics_properties_default.cc',
'graphics/osd_plane_default.cc'
], ],
} }
] ]
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/scoped_ptr.h"
#include "chromecast/public/graphics_types.h"
#include "chromecast/public/osd_plane.h"
#include "chromecast/public/osd_plane_shlib.h"
#include "chromecast/public/osd_surface.h"
namespace chromecast {
namespace {
// Default no-op OsdSurface implementation
class OsdSurfaceDefault : public OsdSurface {
public:
OsdSurfaceDefault(const Size& size) : size_(size) {}
// OsdSurface implementation:
void Blit(OsdSurface* src_surface,
const Rect& src_rect,
const Point& dst_point) override {}
void Composite(OsdSurface* src_surface,
const Rect& src_rect,
const Point& dst_point) override {}
void CopyBitmap(char* src_bitmap,
const Rect& src_rect,
const Rect& damage_rect,
const Point& dst_point) override {}
void Fill(const Rect& rect, int argb) override {}
const Size& size() const override { return size_; }
private:
const Size size_;
DISALLOW_COPY_AND_ASSIGN(OsdSurfaceDefault);
};
// Default no-op OsdPlane implementation
class OsdPlaneDefault : public OsdPlane {
public:
OsdPlaneDefault() : size_(0, 0) {}
// OsdPlane implementation:
OsdSurface* CreateSurface(const Size& size) override {
return new OsdSurfaceDefault(size);
}
void SetClipRectangle(const Rect& rect) override {
size_ = Size(rect.width, rect.height);
}
OsdSurface* GetBackBuffer() override {
if (!back_buffer_)
back_buffer_.reset(new OsdSurfaceDefault(size_));
return back_buffer_.get();
}
void Flip() override {}
private:
scoped_ptr<OsdSurface> back_buffer_;
Size size_;
DISALLOW_COPY_AND_ASSIGN(OsdPlaneDefault);
};
} // namespace
OsdPlane* OsdPlaneShlib::Create(const std::vector<std::string>& argv) {
return new OsdPlaneDefault;
}
} // namespace chromecast
...@@ -7,17 +7,13 @@ ...@@ -7,17 +7,13 @@
namespace chromecast { namespace chromecast {
struct Size;
// Interface representing all the hardware-specific elements of an Ozone // Interface representing all the hardware-specific elements of an Ozone
// implementation for Cast. Supply an implementation of this interface // implementation for Cast. Supply an implementation of this interface
// to OzonePlatformCast to create a complete Ozone implementation. // to OzonePlatformCast to create a complete Ozone implementation.
class CastEglPlatform { class CastEglPlatform {
public: public:
struct Size {
Size(int w, int h) : width(w), height(h) {}
const int width;
const int height;
};
typedef void* (*GLGetProcAddressProc)(const char* name); typedef void* (*GLGetProcAddressProc)(const char* name);
typedef void* NativeDisplayType; typedef void* NativeDisplayType;
typedef void* NativeWindowType; typedef void* NativeWindowType;
......
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_PUBLIC_GRAPHICS_TYPES_H_
#define CHROMECAST_PUBLIC_GRAPHICS_TYPES_H_
namespace chromecast {
struct Rect {
Rect(int w, int h) : x(0), y(0), width(w), height(h) {}
Rect(int arg_x, int arg_y, int w, int h)
: x(arg_x), y(arg_y), width(w), height(h) {}
int x;
int y;
int width;
int height;
};
struct Size {
Size(int w, int h) : width(w), height(h) {}
int width;
int height;
};
} // namespace chromecast
#endif // CHROMECAST_PUBLIC_GRAPHICS_TYPES_H_
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_PUBLIC_OSD_PLANE_H_
#define CHROMECAST_PUBLIC_OSD_PLANE_H_
namespace chromecast {
class OsdSurface;
struct Rect;
struct Size;
// Abstract graphics plane for OSD, to be implemented in platform-specific way.
// Platform must composite this plane on top of main (GL-based) graphics plane.
class OsdPlane {
public:
virtual ~OsdPlane() {}
// Creates a surface for offscreen drawing.
virtual OsdSurface* CreateSurface(const Size& size) = 0;
// Sets a clip rectangle, client should call before drawing to back buffer
// to specify the area they intend to draw on. Platforms may reduce memory
// usage by only allocating back buffer to cover this area. Areas outside
// clip rectangle must display as fully transparent. In particular, setting
// an empty clip rectangle and calling Flip should clear the plane.
virtual void SetClipRectangle(const Rect& rect) = 0;
// Gets the current back buffer surface. Valid until next call to Flip or
// SetClipRectangle.
virtual OsdSurface* GetBackBuffer() = 0;
// Presents current back buffer to screen.
virtual void Flip() = 0;
};
} // namespace chromecast
#endif // CHROMECAST_PUBLIC_OSD_PLANE_H
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_PUBLIC_OSD_PLANE_SHLIB_H_
#define CHROMECAST_PUBLIC_OSD_PLANE_SHLIB_H_
#include <string>
#include <vector>
#include "chromecast_export.h"
namespace chromecast {
class OsdPlane;
// Entry point for loading OsdPlane from shared library.
class CHROMECAST_EXPORT OsdPlaneShlib {
public:
static OsdPlane* Create(const std::vector<std::string>& argv);
};
} // namespace chromecast
#endif // CHROMECAST_PUBLIC_OSD_PLANE_SHLIB_H_
// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_PUBLIC_OSD_SURFACE_H_
#define CHROMECAST_PUBLIC_OSD_SURFACE_H_
namespace chromecast {
struct Rect;
struct Size;
// Provides simple API (copy bitmap, blit, composite and fill) for drawing
// OSD graphics on OsdPlane. Hardware-specific implementation should be
// instantiated by OsdPlane.
class OsdSurface {
public:
struct Point {
Point(int arg_x, int arg_y) : x(arg_x), y(arg_y) {}
const int x;
const int y;
};
virtual ~OsdSurface() {}
// Blits(fast copy) bitmap from a surface. Copies |src_rect| area of surface
// |dst_point| of this surface.
virtual void Blit(OsdSurface* src_surface,
const Rect& src_rect,
const Point& dst_point) = 0;
// Composites ARGB values of |src_surface| on top of this surface. It is NOT
// copy. Used when displaying OSD images on same plane.
virtual void Composite(OsdSurface* src_surface,
const Rect& src_rect,
const Point& dst_point) = 0;
// Copies |damage_rect| area of src bitmap into |dst_point| of this surface.
// It is similar to Blit() except that it accepts arbitrary bitmap pointer
// instead of surface.
virtual void CopyBitmap(char* src_bitmap,
const Rect& src_rect,
const Rect& damage_rect,
const Point& dst_point) = 0;
// Fills |rect| area of surface with |argb| value.
virtual void Fill(const Rect& rect, int argb) = 0;
// Returns the dimensions of the surface.
virtual const Size& size() const = 0;
};
} // namespace chromecast
#endif // CHROMECAST_PUBLIC_OSD_SURFACE_H_
...@@ -6,14 +6,15 @@ ...@@ -6,14 +6,15 @@
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "chromecast/public/cast_egl_platform.h" #include "chromecast/public/cast_egl_platform.h"
#include "chromecast/public/graphics_types.h"
#include "ui/ozone/platform/cast/surface_ozone_egl_cast.h" #include "ui/ozone/platform/cast/surface_ozone_egl_cast.h"
using chromecast::CastEglPlatform; using chromecast::CastEglPlatform;
namespace ui { namespace ui {
namespace { namespace {
CastEglPlatform::Size FromGfxSize(const gfx::Size& size) { chromecast::Size FromGfxSize(const gfx::Size& size) {
return CastEglPlatform::Size(size.width(), size.height()); return chromecast::Size(size.width(), size.height());
} }
// Hard lower bound on display resolution // Hard lower bound on display resolution
...@@ -75,7 +76,7 @@ void SurfaceFactoryCast::CreateDisplayTypeAndWindowIfNeeded() { ...@@ -75,7 +76,7 @@ void SurfaceFactoryCast::CreateDisplayTypeAndWindowIfNeeded() {
} }
DCHECK_EQ(state_, kInitialized); DCHECK_EQ(state_, kInitialized);
if (!have_display_type_) { if (!have_display_type_) {
CastEglPlatform::Size create_size = FromGfxSize(display_size_); chromecast::Size create_size = FromGfxSize(display_size_);
display_type_ = egl_platform_->CreateDisplayType(create_size); display_type_ = egl_platform_->CreateDisplayType(create_size);
have_display_type_ = true; have_display_type_ = true;
window_ = egl_platform_->CreateWindow(display_type_, create_size); window_ = egl_platform_->CreateWindow(display_type_, create_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment