From 85a1d098b5aa6561bfdccc7f36013fd05575f5c0 Mon Sep 17 00:00:00 2001 From: Kondapally Kalyan Date: Thu, 6 Jun 2013 00:31:48 +0300 Subject: [PATCH] Refactor SharedVideoPlatformSurfaceTizen. This patch separates the platform specific code of SharedVideoPlatformSurfaceTizen from its core logic. SharedVideoPlatformSurfaceTizen is now an abstract base class. Platform specific adaptations can be done by extending the class and implementing the required functions. SharedVideoPlatformSurfaceTizenX extends SharedVideoPlatformSurfaceTizen and implements the support for X backend. --- Source/WebCore/PlatformTizen.cmake | 1 + .../tizen/SharedVideoPlatformSurfaceTizen.cpp | 272 +++------------------ .../tizen/SharedVideoPlatformSurfaceTizen.h | 25 +- .../graphics/gstreamer/tizen/VideoLayerTizen.cpp | 8 +- .../tizen/SharedVideoPlatformSurfaceTizenX.cpp | 149 +++++++++++ .../tizen/SharedVideoPlatformSurfaceTizenX.h | 61 +++++ 6 files changed, 264 insertions(+), 252 deletions(-) create mode 100644 Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.cpp create mode 100644 Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.h diff --git a/Source/WebCore/PlatformTizen.cmake b/Source/WebCore/PlatformTizen.cmake index 258ae0d..c8bb2f2 100755 --- a/Source/WebCore/PlatformTizen.cmake +++ b/Source/WebCore/PlatformTizen.cmake @@ -206,6 +206,7 @@ IF (WTF_USE_ACCELERATED_COMPOSITING AND ENABLE_WEBKIT2) LIST(APPEND WebCore_SOURCES platform/graphics/surfaces/x/X11Helper.cpp platform/graphics/surfaces/egl/EGLXSurface.cpp + platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.cpp ) ENDIF() ENDIF() diff --git a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp index 397130a..dad93d1 100644 --- a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.cpp @@ -24,284 +24,90 @@ */ #include "config.h" +#include "SharedVideoPlatformSurfaceTizen.h" #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) -#include "SharedVideoPlatformSurfaceTizen.h" -#include "GraphicsContextPlatformPrivateCairo.h" -#include "IntRect.h" -#include -#include -#include -#include +#include "GraphicsContext.h" #if ENABLE(TIZEN_CANVAS_GRAPHICS_SURFACE) #include "GraphicsSurface.h" #endif -namespace WebCore { - -class VideoPlatformSurface { -public: - static PassOwnPtr create(IntSize size); - ~VideoPlatformSurface(); - - int id() const { return m_platformSurface; } - void paintCurrentFrameInContext(GraphicsContext*, const IntRect&); - void copySurface(VideoPlatformSurface* other, SharedVideoPlatformSurfaceTizen::CopySurfaceType type); - bool hasAlpha() { return m_hasAlpha; } - -private: - VideoPlatformSurface(); - - bool initialize(IntSize size); - bool createPlatformSurface(IntSize size); - bool destroyPlatformSurface(); - void clearPlatformSurface(); +#if PLATFORM(X11) +#include "SharedVideoPlatformSurfaceTizenX.h" +#endif - int m_platformSurface; - int m_nativeWindow; - Display* m_nativeDisplay; +namespace WebCore { - IntSize m_size; - bool m_hasAlpha; -}; +PassOwnPtr SharedVideoPlatformSurfaceTizen::create(IntSize size) +{ +#if PLATFORM(X11) + return adoptPtr(new SharedVideoPlatformSurfaceTizenX(size)); +#else + return nullptr; +#endif +} -PassOwnPtr VideoPlatformSurface::create(IntSize size) +SharedVideoPlatformSurfaceTizen::SharedVideoPlatformSurfaceTizen(const IntSize& size) + : GLPlatformSurface() + , m_listener(0) { - OwnPtr videoPlatformSurface = adoptPtr(new VideoPlatformSurface()); - if (!videoPlatformSurface->initialize(size)) - return nullptr; - return videoPlatformSurface.release(); + m_flags = GraphicsSurface::Is2D | GraphicsSurface::UseLinearFilter | GraphicsSurface::Alpha; + m_rect = IntRect(0, 0, size.width(), size.height()); } -VideoPlatformSurface::VideoPlatformSurface() - : m_platformSurface(0) - , m_nativeWindow(0) - , m_nativeDisplay(0) - , m_size(IntSize()) - , m_hasAlpha(true) +SharedVideoPlatformSurfaceTizen::~SharedVideoPlatformSurfaceTizen() { + m_listener = 0; } -VideoPlatformSurface::~VideoPlatformSurface() +void SharedVideoPlatformSurfaceTizen::setVideoPlatformSurfaceUpdateListener(VideoPlatformSurfaceUpdateListener* listener) { - destroyPlatformSurface(); + m_listener = listener; } -void VideoPlatformSurface::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect) +void SharedVideoPlatformSurfaceTizen::platformSurfaceUpdated() { - if (context->paintingDisabled()) - return; + if (m_listener) + m_listener->platformSurfaceUpdated(); +} - if (m_size.isEmpty()) +void SharedVideoPlatformSurfaceTizen::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect) +{ + if (!m_bufferHandle || context->paintingDisabled()) return; - cairo_surface_t* surface = cairo_xlib_surface_create(m_nativeDisplay, m_platformSurface, DefaultVisual(m_nativeDisplay, DefaultScreen(m_nativeDisplay)), m_size.width(), m_size.height()); - if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) + if (m_rect.isEmpty()) return; - cairo_t* cr = context->platformContext()->cr(); - cairo_save(cr); - - cairo_set_source_surface(cr, surface, 0, 0); - cairo_paint(cr); - - cairo_restore(cr); - cairo_surface_destroy(surface); + platformPaintCurrentFrameInContext(context, rect); } -void VideoPlatformSurface::copySurface(VideoPlatformSurface* other, SharedVideoPlatformSurfaceTizen::CopySurfaceType type) +void SharedVideoPlatformSurfaceTizen::copySurface(SharedVideoPlatformSurfaceTizen* other, CopySurfaceType type) { - RefPtr surface = adoptRef(cairo_xlib_surface_create(m_nativeDisplay, m_platformSurface, DefaultVisual(m_nativeDisplay, DefaultScreen(m_nativeDisplay)), m_size.width(), m_size.height())); - RefPtr context = adoptRef(cairo_create(surface.get())); - OwnPtr graphicsContext = adoptPtr(new GraphicsContext(context.get())); - - float xScale = static_cast(m_size.width()) / other->m_size.width(); - float yScale = static_cast(m_size.height()) / other->m_size.height(); + IntRect targetGeometry = other->geometry(); + float xScale = static_cast(m_rect.width()) / targetGeometry.width(); + float yScale = static_cast(m_rect.height()) / targetGeometry.height(); float xPosition = 0; float yPosition = 0; if (xScale != yScale) { switch (type) { case SharedVideoPlatformSurfaceTizen::FitToWidth: - yPosition = (m_size.height() - other->m_size.height() * xScale) / 2; + yPosition = (m_rect.height() - targetGeometry.height() * xScale) / 2; yScale = xScale; break; case SharedVideoPlatformSurfaceTizen::FitToHeight: - xPosition = (m_size.width() - other->m_size.width() * yScale) / 2; + xPosition = (m_rect.width() - targetGeometry.width() * yScale) / 2; xScale = yScale; break; default: break; } } - graphicsContext->translate(xPosition, yPosition); - graphicsContext->scale(FloatSize(xScale, yScale)); - other->paintCurrentFrameInContext(graphicsContext.get(), IntRect()); -} - -bool VideoPlatformSurface::initialize(IntSize size) -{ - if (!createPlatformSurface(size)) - return false; - - m_size = size; - - clearPlatformSurface(); - - return true; -} - -bool VideoPlatformSurface::createPlatformSurface(IntSize size) -{ - if (size.isEmpty()) - return false; - - if (!m_nativeDisplay) { -#ifdef HAVE_ECORE_X - ecore_x_init(0); - m_nativeDisplay = (Display*)ecore_x_display_get(); -#else - m_nativeDisplay = 0; -#endif - } - - if (!m_nativeWindow) - m_nativeWindow = XCreateSimpleWindow(m_nativeDisplay, DefaultRootWindow(m_nativeDisplay), 0, 0, 1, 1, 0, BlackPixel(m_nativeDisplay, 0), WhitePixel(m_nativeDisplay, 0)); - - XSync(m_nativeDisplay, false); - - int visualDepth = XDefaultDepth(m_nativeDisplay, DefaultScreen(m_nativeDisplay)); - m_platformSurface = XCreatePixmap(m_nativeDisplay, m_nativeWindow, size.width(), size.height(), visualDepth); - - XFlush(m_nativeDisplay); - -#if USE(ACCELERATED_VIDEO_VAAPI) - m_hasAlpha = visualDepth == 32 ? true : false; -#endif - - return true; -} - -bool VideoPlatformSurface::destroyPlatformSurface() -{ - if (m_platformSurface) { - XFreePixmap(m_nativeDisplay, m_platformSurface); - m_platformSurface = 0; - } - - if (m_nativeWindow) { - XDestroyWindow(m_nativeDisplay, m_nativeWindow); - m_nativeWindow = 0; - } - - m_nativeDisplay = 0; - - return true; -} -void VideoPlatformSurface::clearPlatformSurface() -{ - RefPtr surface = adoptRef(cairo_xlib_surface_create(m_nativeDisplay, m_platformSurface, DefaultVisual(m_nativeDisplay, DefaultScreen(m_nativeDisplay)), m_size.width(), m_size.height())); - if (cairo_surface_status(surface.get()) != CAIRO_STATUS_SUCCESS) - return; - - RefPtr cr = adoptRef(cairo_create(surface.get())); - cairo_set_source_surface(cr.get(), surface.get(), 0, 0); - int alphaValue = m_hasAlpha ? 1 : 0; - cairo_set_source_rgba(cr.get(), 0, 0, 0, alphaValue); - cairo_rectangle(cr.get(), 0, 0, m_size.width(), m_size.height()); - cairo_fill(cr.get()); -} - -PassOwnPtr SharedVideoPlatformSurfaceTizen::create(IntSize size) -{ - return adoptPtr(new SharedVideoPlatformSurfaceTizen(size)); -} - -SharedVideoPlatformSurfaceTizen::SharedVideoPlatformSurfaceTizen(IntSize size) - : m_damage(0) - , m_damageHandler(0) - , m_listener(0) - , m_platformSurface(VideoPlatformSurface::create(size)) -{ - if (!m_platformSurface) - return; - - registerDamageHandler(); - m_flags = GraphicsSurface::Is2D | GraphicsSurface::UseLinearFilter; - if (m_platformSurface->hasAlpha()) - m_flags |= GraphicsSurface::Alpha; - -} - -SharedVideoPlatformSurfaceTizen::~SharedVideoPlatformSurfaceTizen() -{ - m_listener = 0; - - unregisterDamageHandler(); -} - -static Eina_Bool notifyDamageUpdated(void* data, int type, void* event) -{ - SharedVideoPlatformSurfaceTizen* sharedVideoPlatformSurface = reinterpret_cast(data); - sharedVideoPlatformSurface->platformSurfaceUpdated(); - - return ECORE_CALLBACK_PASS_ON; -} - -int SharedVideoPlatformSurfaceTizen::id() const -{ - return m_platformSurface ? m_platformSurface->id() : 0; -} - -void SharedVideoPlatformSurfaceTizen::platformSurfaceUpdated() -{ - if (m_listener) - m_listener->platformSurfaceUpdated(); -} - -void SharedVideoPlatformSurfaceTizen::setVideoPlatformSurfaceUpdateListener(VideoPlatformSurfaceUpdateListener* listener) -{ - m_listener = listener; -} - -void SharedVideoPlatformSurfaceTizen::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect) -{ - if (m_platformSurface) - m_platformSurface->paintCurrentFrameInContext(context, rect); -} - -void SharedVideoPlatformSurfaceTizen::copySurface(SharedVideoPlatformSurfaceTizen* other, CopySurfaceType type) -{ - if (m_platformSurface) - m_platformSurface->copySurface(other->m_platformSurface.get(), type); -} - -void SharedVideoPlatformSurfaceTizen::registerDamageHandler() -{ - if (!m_platformSurface) - return; -#ifdef HAVE_ECORE_X - m_damage = ecore_x_damage_new(m_platformSurface->id(), ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES); - m_damageHandler = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY, notifyDamageUpdated, this); -#endif -} - -void SharedVideoPlatformSurfaceTizen::unregisterDamageHandler() -{ -#ifdef HAVE_ECORE_X - if (m_damage) { - ecore_x_damage_free(m_damage); - m_damage = 0; - } - - if (m_damageHandler) { - ecore_event_handler_del(m_damageHandler); - m_damageHandler = 0; - } -#endif + platformCopySurface(other, xPosition, xScale, yPosition, yScale); } int SharedVideoPlatformSurfaceTizen::graphicsSurfaceFlags() const diff --git a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h index 453b8ee..f828c26 100644 --- a/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h +++ b/Source/WebCore/platform/graphics/gstreamer/tizen/SharedVideoPlatformSurfaceTizen.h @@ -22,24 +22,24 @@ #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) +#include "GLPlatformSurface.h" #include "IntSize.h" -#include -#include #include +#include #include namespace WebCore { class GraphicsContext; class IntRect; -class VideoPlatformSurface; class VideoPlatformSurfaceUpdateListener { public: virtual void platformSurfaceUpdated() = 0; }; -class SharedVideoPlatformSurfaceTizen { +class SharedVideoPlatformSurfaceTizen : public GLPlatformSurface { + WTF_MAKE_NONCOPYABLE(SharedVideoPlatformSurfaceTizen); public: enum CopySurfaceType { FitToWidth, @@ -50,24 +50,19 @@ public: static PassOwnPtr create(IntSize size); ~SharedVideoPlatformSurfaceTizen(); - int id() const; - void platformSurfaceUpdated(); void setVideoPlatformSurfaceUpdateListener(VideoPlatformSurfaceUpdateListener* listener); void paintCurrentFrameInContext(GraphicsContext*, const IntRect&); void copySurface(SharedVideoPlatformSurfaceTizen*, CopySurfaceType); + void platformSurfaceUpdated(); int graphicsSurfaceFlags() const; +protected: + SharedVideoPlatformSurfaceTizen(const IntSize&); + virtual void platformCopySurface(SharedVideoPlatformSurfaceTizen*, float, float, float, float) = 0; + virtual void platformPaintCurrentFrameInContext(GraphicsContext*, const IntRect&) = 0; + int m_flags; private: - SharedVideoPlatformSurfaceTizen(IntSize size); - - void registerDamageHandler(); - void unregisterDamageHandler(); - - Ecore_X_Damage m_damage; - Ecore_Event_Handler* m_damageHandler; VideoPlatformSurfaceUpdateListener* m_listener; - OwnPtr m_platformSurface; - int m_flags; }; } // WebCore diff --git a/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp b/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp index fd0d16e..8381795 100644 --- a/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/tizen/VideoLayerTizen.cpp @@ -188,9 +188,9 @@ void VideoLayerTizen::setOverlay(IntSize size) m_platformSurface->copySurface(m_platformSurfaceToBeRemoved.get(), SharedVideoPlatformSurfaceTizen::FitToWidth); #ifdef GST_API_VERSION_1 - gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(m_videoSink), m_platformSurface->id()); + gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(m_videoSink), m_platformSurface->handle()); #else - gst_x_overlay_set_window_handle(GST_X_OVERLAY(m_videoSink), m_platformSurface->id()); + gst_x_overlay_set_window_handle(GST_X_OVERLAY(m_videoSink), m_platformSurface->handle()); #endif #if !USE(ACCELERATED_VIDEO_VAAPI) g_object_set(m_videoSink, "rotate", 0, NULL); @@ -239,7 +239,7 @@ void VideoLayerTizen::paintVideoLayer(IntSize videoSize) PlatformBufferHandle VideoLayerTizen::graphicsSurfaceToken() const { #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) - return (m_platformSurface ? m_platformSurface->id() : 0); + return (m_platformSurface ? m_platformSurface->handle() : 0); #else return m_platformSurfaceID; #endif @@ -248,7 +248,7 @@ PlatformBufferHandle VideoLayerTizen::graphicsSurfaceToken() const PlatformBufferHandle VideoLayerTizen::copyToGraphicsSurface() { #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE) - return (m_platformSurface ? m_platformSurface->id() : 0); + return (m_platformSurface ? m_platformSurface->handle() : 0); #else return m_platformSurfaceID; #endif diff --git a/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.cpp b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.cpp new file mode 100644 index 0000000..f1b093a --- /dev/null +++ b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "SharedVideoPlatformSurfaceTizenX.h" + +#if PLATFORM(X11) && USE(EGL) + +#include "GraphicsSurface.h" +#include "PlatformContextCairo.h" + +#include +#include + +namespace WebCore { + +SharedVideoPlatformSurfaceTizenX::SharedVideoPlatformSurfaceTizenX(const IntSize& size) + : SharedVideoPlatformSurfaceTizen(size) + , m_damage(0) + , m_damageHandler(0) +{ + int visualDepth; + Pixmap pixmap; + X11Helper::createPixmap(&pixmap, &visualDepth, size); + m_bufferHandle = pixmap; + + if (!m_bufferHandle) + return; + +#if USE(ACCELERATED_VIDEO_VAAPI) + if (visualDepth != 32) + m_flags &= ~GraphicsSurface::Alpha; +#endif + clearPlatformSurface(); + registerDamageHandler(); +} + +SharedVideoPlatformSurfaceTizenX::~SharedVideoPlatformSurfaceTizenX() +{ + unregisterDamageHandler(); + destroy(); +} + +void SharedVideoPlatformSurfaceTizenX::destroy() +{ + if (m_bufferHandle) { + X11Helper::destroyPixmap(m_bufferHandle); + m_bufferHandle = 0; + } +} + +void SharedVideoPlatformSurfaceTizenX::platformPaintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect) +{ + Display* display = X11Helper::nativeDisplay(); + cairo_surface_t* surface = cairo_xlib_surface_create(display, m_bufferHandle, DefaultVisual(display, DefaultScreen(display)), m_rect.width(), m_rect.height()); + if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) + return; + + cairo_t* cr = context->platformContext()->cr(); + cairo_save(cr); + + cairo_set_source_surface(cr, surface, 0, 0); + cairo_paint(cr); + + cairo_restore(cr); + cairo_surface_destroy(surface); +} + +void SharedVideoPlatformSurfaceTizenX::platformCopySurface(SharedVideoPlatformSurfaceTizen* other, float xPosition, float xScale, float yPosition, float yScale) +{ + Display* display = X11Helper::nativeDisplay(); + RefPtr surface = adoptRef(cairo_xlib_surface_create(display, m_bufferHandle, DefaultVisual(display, DefaultScreen(display)), m_rect.width(), m_rect.height())); + RefPtr context = adoptRef(cairo_create(surface.get())); + OwnPtr graphicsContext = adoptPtr(new GraphicsContext(context.get())); + graphicsContext->translate(xPosition, yPosition); + graphicsContext->scale(FloatSize(xScale, yScale)); + other->paintCurrentFrameInContext(graphicsContext.get(), IntRect()); +} + +void SharedVideoPlatformSurfaceTizenX::clearPlatformSurface() +{ + Display* display = X11Helper::nativeDisplay(); + RefPtr surface = adoptRef(cairo_xlib_surface_create(display, m_bufferHandle, DefaultVisual(display, DefaultScreen(display)), m_rect.width(), m_rect.height())); + if (cairo_surface_status(surface.get()) != CAIRO_STATUS_SUCCESS) + return; + + RefPtr cr = adoptRef(cairo_create(surface.get())); + cairo_set_source_surface(cr.get(), surface.get(), 0, 0); + int alphaValue = m_flags & GraphicsSurface::Alpha ? 1 : 0; + cairo_set_source_rgba(cr.get(), 0, 0, 0, alphaValue); + cairo_rectangle(cr.get(), 0, 0, m_rect.width(), m_rect.height()); + cairo_fill(cr.get()); +} + +static Eina_Bool notifyDamageUpdated(void* data, int type, void* event) +{ + SharedVideoPlatformSurfaceTizen* sharedVideoPlatformSurface = reinterpret_cast(data); + sharedVideoPlatformSurface->platformSurfaceUpdated(); + + return ECORE_CALLBACK_PASS_ON; +} + +void SharedVideoPlatformSurfaceTizenX::registerDamageHandler() +{ + if (!m_bufferHandle) + return; + + m_damage = ecore_x_damage_new(m_bufferHandle, ECORE_X_DAMAGE_REPORT_RAW_RECTANGLES); + m_damageHandler = ecore_event_handler_add(ECORE_X_EVENT_DAMAGE_NOTIFY, notifyDamageUpdated, this); +} + +void SharedVideoPlatformSurfaceTizenX::unregisterDamageHandler() +{ + if (m_damage) { + ecore_x_damage_free(m_damage); + m_damage = 0; + } + + if (m_damageHandler) { + ecore_event_handler_del(m_damageHandler); + m_damageHandler = 0; + } +} + +} + +#endif diff --git a/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.h b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.h new file mode 100644 index 0000000..08def59 --- /dev/null +++ b/Source/WebCore/platform/graphics/surfaces/tizen/SharedVideoPlatformSurfaceTizenX.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 Intel Corporation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SharedVideoPlatformSurfaceTizenX_h +#define SharedVideoPlatformSurfaceTizenX_h + +#if PLATFORM(X11) + +#include "SharedVideoPlatformSurfaceTizen.h" +#include "X11Helper.h" + +#include +#include + +namespace WebCore { + +class SharedVideoPlatformSurfaceTizenX : public SharedVideoPlatformSurfaceTizen { +public: + SharedVideoPlatformSurfaceTizenX(const IntSize&); + virtual ~SharedVideoPlatformSurfaceTizenX(); + +protected: + virtual void platformCopySurface(SharedVideoPlatformSurfaceTizen* other, float xPosition, float xScale, float yPosition, float yScale) OVERRIDE; + virtual void platformPaintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect) OVERRIDE; + virtual void destroy(); +private: + void clearPlatformSurface(); + void registerDamageHandler(); + void unregisterDamageHandler(); + Ecore_X_Damage m_damage; + Ecore_Event_Handler* m_damageHandler; +}; + +} + +#endif + +#endif + -- 2.7.4