| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | |
| 3 | |
| 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. | |
| 8 | |
| 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. | |
| 13 | |
| 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. | |
| 18 */ | |
| 19 | |
| 20 #ifndef GraphicsSurface_h | |
| 21 #define GraphicsSurface_h | |
| 22 | |
| 23 #if USE(GRAPHICS_SURFACE) | |
| 24 | |
| 25 #include "GraphicsContext.h" | |
| 26 #include "GraphicsContext3D.h" | |
| 27 #include "GraphicsSurfaceToken.h" | |
| 28 #include "IntRect.h" | |
| 29 #include <wtf/OwnPtr.h> | |
| 30 #include <wtf/PassOwnPtr.h> | |
| 31 #include <wtf/RefCounted.h> | |
| 32 #include <wtf/RefPtr.h> | |
| 33 | |
| 34 #if OS(DARWIN) | |
| 35 typedef struct __IOSurface* IOSurfaceRef; | |
| 36 typedef IOSurfaceRef PlatformGraphicsSurface; | |
| 37 #endif | |
| 38 | |
| 39 #if OS(LINUX) | |
| 40 typedef uint32_t PlatformGraphicsSurface; | |
| 41 #endif | |
| 42 | |
| 43 #if OS(WINDOWS) | |
| 44 typedef HANDLE PlatformGraphicsSurface; | |
| 45 #endif | |
| 46 | |
| 47 namespace WebCore { | |
| 48 | |
| 49 class BitmapTexture; | |
| 50 class TextureMapper; | |
| 51 struct GraphicsSurfacePrivate; | |
| 52 | |
| 53 class GraphicsSurface : public RefCounted<GraphicsSurface> { | |
| 54 public: | |
| 55 enum Flag { | |
| 56 SupportsAlpha = 0x01, | |
| 57 SupportsSoftwareWrite = 0x02, | |
| 58 SupportsSoftwareRead = 0x04, | |
| 59 SupportsTextureTarget = 0x08, | |
| 60 SupportsTextureSource = 0x10, | |
| 61 SupportsCopyToTexture = 0x20, | |
| 62 SupportsCopyFromTexture = 0x40, | |
| 63 SupportsSharing = 0x80, | |
| 64 SupportsSingleBuffered = 0x100 | |
| 65 }; | |
| 66 | |
| 67 enum LockOption { | |
| 68 RetainPixels = 0x01, | |
| 69 ReadOnly = 0x02 | |
| 70 }; | |
| 71 | |
| 72 typedef int Flags; | |
| 73 typedef int LockOptions; | |
| 74 | |
| 75 Flags flags() const { return m_flags; } | |
| 76 IntSize size() const; | |
| 77 | |
| 78 static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const Platf
ormGraphicsContext3D shareContext = 0); | |
| 79 static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const Graph
icsSurfaceToken&); | |
| 80 void copyToGLTexture(uint32_t target, uint32_t texture, const IntRect& targe
tRect, const IntPoint& sourceOffset); | |
| 81 void copyFromTexture(uint32_t texture, const IntRect& sourceRect); | |
| 82 void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const
TransformationMatrix&, float opacity); | |
| 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&); | |
| 89 ~GraphicsSurface(); | |
| 90 | |
| 91 protected: | |
| 92 static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags, con
st PlatformGraphicsContext3D); | |
| 93 static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, con
st GraphicsSurfaceToken&); | |
| 94 GraphicsSurfaceToken platformExport(); | |
| 95 void platformDestroy(); | |
| 96 | |
| 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 IntRec
t&, const IntPoint&); | |
| 101 void platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect); | |
| 102 void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRec
t, const TransformationMatrix&, float opacity); | |
| 103 uint32_t platformFrontBuffer() const; | |
| 104 uint32_t platformSwapBuffers(); | |
| 105 IntSize platformSize() const; | |
| 106 | |
| 107 PassOwnPtr<GraphicsContext> platformBeginPaint(const IntSize&, char* bits, i
nt stride); | |
| 108 | |
| 109 protected: | |
| 110 LockOptions m_lockOptions; | |
| 111 Flags m_flags; | |
| 112 | |
| 113 private: | |
| 114 GraphicsSurface(const IntSize&, Flags); | |
| 115 | |
| 116 uint32_t m_fbo; | |
| 117 GraphicsSurfacePrivate* m_private; | |
| 118 }; | |
| 119 | |
| 120 } | |
| 121 #endif // USE(GRAPHICS_SURFACE) | |
| 122 | |
| 123 #endif // GraphicsSurface_h | |
| OLD | NEW |