[TexMap] Seperate BitmapTexture related classes implementations from TextureMapper
[WebKit-https.git] / Source / WebKit2 / Shared / CoordinatedGraphics / WebCoordinatedSurface.cpp
index 52b7f6d..7feaeea 100644 (file)
@@ -28,6 +28,7 @@
 #include <WebCore/GraphicsSurfaceToken.h>
 
 #if USE(TEXTURE_MAPPER)
+#include "BitmapTextureGL.h"
 #include "TextureMapperGL.h"
 #endif
 
@@ -39,7 +40,7 @@ WebCoordinatedSurface::Handle::Handle()
 {
 }
 
-void WebCoordinatedSurface::Handle::encode(CoreIPC::ArgumentEncoder& encoder) const
+void WebCoordinatedSurface::Handle::encode(IPC::ArgumentEncoder& encoder) const
 {
     encoder << m_size << m_flags;
 #if USE(GRAPHICS_SURFACE)
@@ -50,7 +51,7 @@ void WebCoordinatedSurface::Handle::encode(CoreIPC::ArgumentEncoder& encoder) co
     encoder << m_bitmapHandle;
 }
 
-bool WebCoordinatedSurface::Handle::decode(CoreIPC::ArgumentDecoder& decoder, Handle& handle)
+bool WebCoordinatedSurface::Handle::decode(IPC::ArgumentDecoder& decoder, Handle& handle)
 {
     if (!decoder.decode(handle.m_size))
         return false;
@@ -103,7 +104,7 @@ PassRefPtr<WebCoordinatedSurface> WebCoordinatedSurface::createWithSurface(const
 }
 #endif
 
-PassOwnPtr<WebCore::GraphicsContext> WebCoordinatedSurface::createGraphicsContext(const IntRect& rect)
+std::unique_ptr<GraphicsContext> WebCoordinatedSurface::createGraphicsContext(const IntRect& rect)
 {
 #if USE(GRAPHICS_SURFACE)
     if (isBackedByGraphicsSurface())
@@ -111,10 +112,10 @@ PassOwnPtr<WebCore::GraphicsContext> WebCoordinatedSurface::createGraphicsContex
 #endif
 
     ASSERT(m_bitmap);
-    OwnPtr<GraphicsContext> graphicsContext = m_bitmap->createGraphicsContext();
+    auto graphicsContext = m_bitmap->createGraphicsContext();
     graphicsContext->clip(rect);
     graphicsContext->translate(rect.x(), rect.y());
-    return graphicsContext.release();
+    return graphicsContext;
 }
 
 PassRefPtr<WebCoordinatedSurface> WebCoordinatedSurface::create(const IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<ShareableBitmap> bitmap)
@@ -123,16 +124,14 @@ PassRefPtr<WebCoordinatedSurface> WebCoordinatedSurface::create(const IntSize& s
 }
 
 WebCoordinatedSurface::WebCoordinatedSurface(const IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<ShareableBitmap> bitmap)
-    : m_size(size)
-    , m_flags(flags)
+    : CoordinatedSurface(size, flags)
     , m_bitmap(bitmap)
 {
 }
 
 #if USE(GRAPHICS_SURFACE)
 WebCoordinatedSurface::WebCoordinatedSurface(const WebCore::IntSize& size, CoordinatedSurface::Flags flags, PassRefPtr<WebCore::GraphicsSurface> surface)
-    : m_size(size)
-    , m_flags(flags)
+    : CoordinatedSurface(size, flags)
     , m_graphicsSurface(surface)
 {
 }
@@ -156,7 +155,7 @@ PassRefPtr<WebCoordinatedSurface> WebCoordinatedSurface::create(const Handle& ha
             surfaceFlags |= GraphicsSurface::SupportsAlpha;
         RefPtr<GraphicsSurface> surface = GraphicsSurface::create(handle.m_size, surfaceFlags, handle.m_graphicsSurfaceToken);
         if (surface)
-            return adoptRef(new WebCoordinatedSurface(handle.m_size, handle.m_flags, PassRefPtr<GraphicsSurface>(surface)));
+            return adoptRef(new WebCoordinatedSurface(handle.m_size, handle.m_flags, surface.release()));
     }
 #endif
 
@@ -183,6 +182,14 @@ bool WebCoordinatedSurface::createHandle(Handle& handle)
     return true;
 }
 
+void WebCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
+{
+    ASSERT(client);
+
+    auto context = createGraphicsContext(rect);
+    client->paintToSurfaceContext(context.get());
+}
+
 #if USE(TEXTURE_MAPPER)
 void WebCoordinatedSurface::copyToTexture(PassRefPtr<WebCore::BitmapTexture> passTexture, const IntRect& target, const IntPoint& sourceOffset)
 {