int id() const { return m_platformSurface; }
void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
- void copySurface(VideoPlatformSurface* other);
+ void copySurface(VideoPlatformSurface* other, SharedVideoPlatformSurfaceTizen::CopySurfaceType type);
bool hasAlpha() { return m_hasAlpha; }
private:
cairo_surface_destroy(surface);
}
-void VideoPlatformSurface::copySurface(VideoPlatformSurface* other)
+void VideoPlatformSurface::copySurface(VideoPlatformSurface* other, SharedVideoPlatformSurfaceTizen::CopySurfaceType type)
{
RefPtr<cairo_surface_t> surface = adoptRef(cairo_xlib_surface_create(m_nativeDisplay, m_platformSurface, DefaultVisual(m_nativeDisplay, DefaultScreen(m_nativeDisplay)), m_size.width(), m_size.height()));
RefPtr<cairo_t> context = adoptRef(cairo_create(surface.get()));
float xScale = static_cast<float>(m_size.width()) / other->m_size.width();
float yScale = static_cast<float>(m_size.height()) / other->m_size.height();
+ float xPosition = 0;
+ float yPosition = 0;
- // Fit to width. (scale using xScale.)
- // Copy to center of destination surface.
if (xScale != yScale) {
- float yPosition = (m_size.height() - other->m_size.height() * xScale) / 2;
- graphicsContext->translate(0, yPosition);
+ switch (type) {
+ case SharedVideoPlatformSurfaceTizen::FitToWidth:
+ yPosition = (m_size.height() - other->m_size.height() * xScale) / 2;
+ yScale = xScale;
+ break;
+ case SharedVideoPlatformSurfaceTizen::FitToHeight:
+ xPosition = (m_size.width() - other->m_size.width() * yScale) / 2;
+ xScale = yScale;
+ break;
+ }
}
- graphicsContext->scale(FloatSize(xScale, xScale));
+ graphicsContext->translate(xPosition, yPosition);
+ graphicsContext->scale(FloatSize(xScale, yScale));
other->paintCurrentFrameInContext(graphicsContext.get(), IntRect());
}
m_platformSurface->paintCurrentFrameInContext(context, rect);
}
-void SharedVideoPlatformSurfaceTizen::copySurface(SharedVideoPlatformSurfaceTizen* other)
+void SharedVideoPlatformSurfaceTizen::copySurface(SharedVideoPlatformSurfaceTizen* other, CopySurfaceType type)
{
if (m_platformSurface)
- m_platformSurface->copySurface(other->m_platformSurface.get());
+ m_platformSurface->copySurface(other->m_platformSurface.get(), type);
}
void SharedVideoPlatformSurfaceTizen::registerDamageHandler()
class SharedVideoPlatformSurfaceTizen {
public:
+ enum CopySurfaceType {
+ FitToWidth,
+ FitToHeight,
+ FitToRect
+ };
+
static PassOwnPtr<SharedVideoPlatformSurfaceTizen> create(IntSize size);
~SharedVideoPlatformSurfaceTizen();
void platformSurfaceUpdated();
void setVideoPlatformSurfaceUpdateListener(VideoPlatformSurfaceUpdateListener* listener);
void paintCurrentFrameInContext(GraphicsContext*, const IntRect&);
- void copySurface(SharedVideoPlatformSurfaceTizen*);
+ void copySurface(SharedVideoPlatformSurfaceTizen*, CopySurfaceType);
int graphicsSurfaceFlags() const;
private: