2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef GraphicsSurface_h
21 #define GraphicsSurface_h
23 #if USE(GRAPHICS_SURFACE)
25 #include "GraphicsContext.h"
26 #include "GraphicsContext3D.h"
27 #include "GraphicsSurfaceToken.h"
29 #include <wtf/OwnPtr.h>
30 #include <wtf/PassOwnPtr.h>
31 #include <wtf/RefCounted.h>
32 #include <wtf/RefPtr.h>
35 typedef struct __IOSurface* IOSurfaceRef;
36 typedef IOSurfaceRef PlatformGraphicsSurface;
40 typedef uint32_t PlatformGraphicsSurface;
44 typedef HANDLE PlatformGraphicsSurface;
51 struct GraphicsSurfacePrivate;
53 class GraphicsSurface : public RefCounted<GraphicsSurface> {
57 SupportsSoftwareWrite = 0x02,
58 SupportsSoftwareRead = 0x04,
59 SupportsTextureTarget = 0x08,
60 SupportsTextureSource = 0x10,
61 SupportsCopyToTexture = 0x20,
62 SupportsCopyFromTexture = 0x40,
63 SupportsSharing = 0x80,
64 SupportsSingleBuffered = 0x100
73 typedef int LockOptions;
75 Flags flags() const { return m_flags; }
78 static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const PlatformGraphicsContext3D shareContext = 0);
79 static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const GraphicsSurfaceToken&);
80 void copyToGLTexture(uint32_t target, uint32_t texture, const IntRect& targetRect, const IntPoint& sourceOffset);
81 void copyFromTexture(uint32_t texture, const IntRect& sourceRect);
82 void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
83 uint32_t frontBuffer();
84 uint32_t swapBuffers();
85 GraphicsSurfaceToken exportToken();
86 uint32_t getTextureID();
87 PassOwnPtr<GraphicsContext> beginPaint(const IntRect&, LockOptions);
88 PassRefPtr<Image> createReadOnlyImage(const IntRect&);
92 static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags, const PlatformGraphicsContext3D);
93 static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, const GraphicsSurfaceToken&);
94 GraphicsSurfaceToken platformExport();
95 void platformDestroy();
97 uint32_t platformGetTextureID();
98 char* platformLock(const IntRect&, int* stride, LockOptions);
99 void platformUnlock();
100 void platformCopyToGLTexture(uint32_t target, uint32_t texture, const IntRect&, const IntPoint&);
101 void platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect);
102 void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
103 uint32_t platformFrontBuffer() const;
104 uint32_t platformSwapBuffers();
105 IntSize platformSize() const;
107 PassOwnPtr<GraphicsContext> platformBeginPaint(const IntSize&, char* bits, int stride);
110 LockOptions m_lockOptions;
114 GraphicsSurface(const IntSize&, Flags);
117 static void didReleaseImage(void*);
122 GraphicsSurfacePrivate* m_private;
126 #endif // USE(GRAPHICS_SURFACE)
128 #endif // GraphicsSurface_h