summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/platform/graphics/texmap/TextureMapperGL.h')
-rw-r--r--Source/WebCore/platform/graphics/texmap/TextureMapperGL.h164
1 files changed, 29 insertions, 135 deletions
diff --git a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
index 081403f00..acc78e8c8 100644
--- a/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
+++ b/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h
@@ -1,5 +1,6 @@
/*
Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2015 Igalia S.L.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -20,8 +21,9 @@
#ifndef TextureMapperGL_h
#define TextureMapperGL_h
-#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#if USE(TEXTURE_MAPPER_GL)
+#include "ClipStack.h"
#include "FilterOperation.h"
#include "FloatQuad.h"
#include "GraphicsContext3D.h"
@@ -38,95 +40,49 @@ class FilterOperation;
// An OpenGL-ES2 implementation of TextureMapper.
class TextureMapperGL : public TextureMapper {
public:
- static PassOwnPtr<TextureMapperGL> create() { return adoptPtr(new TextureMapperGL); }
+ TextureMapperGL();
virtual ~TextureMapperGL();
enum Flag {
ShouldBlend = 0x01,
ShouldFlipTexture = 0x02,
ShouldUseARBTextureRect = 0x04,
- ShouldAntialias = 0x08
+ ShouldAntialias = 0x08,
+ ShouldRotateTexture90 = 0x10,
+ ShouldRotateTexture180 = 0x20,
+ ShouldRotateTexture270 = 0x40
};
typedef int Flags;
// TextureMapper implementation
- virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) override;
- virtual void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) override;
- virtual void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, unsigned exposedEdges) override;
+ void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) override;
+ void drawNumber(int number, const Color&, const FloatPoint&, const TransformationMatrix&) override;
+ void drawTexture(const BitmapTexture&, const FloatRect&, const TransformationMatrix&, float opacity, unsigned exposedEdges) override;
virtual void drawTexture(Platform3DObject texture, Flags, const IntSize& textureSize, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity, unsigned exposedEdges = AllEdges);
- virtual void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) override;
-
- virtual void bindSurface(BitmapTexture* surface) override;
- virtual void beginClip(const TransformationMatrix&, const FloatRect&) override;
- virtual void beginPainting(PaintFlags = 0) override;
- virtual void endPainting() override;
- virtual void endClip() override;
- virtual IntRect clipBounds() override;
- virtual IntSize maxTextureSize() const override { return IntSize(2000, 2000); }
- virtual PassRefPtr<BitmapTexture> createTexture() override;
+ void drawSolidColor(const FloatRect&, const TransformationMatrix&, const Color&) override;
+
+ void bindSurface(BitmapTexture* surface) override;
+ BitmapTexture* currentSurface();
+ void beginClip(const TransformationMatrix&, const FloatRect&) override;
+ void beginPainting(PaintFlags = 0) override;
+ void endPainting() override;
+ void endClip() override;
+ IntRect clipBounds() override;
+ IntSize maxTextureSize() const override { return IntSize(2000, 2000); }
+ PassRefPtr<BitmapTexture> createTexture() override;
inline GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); }
-#if ENABLE(CSS_FILTERS)
void drawFiltered(const BitmapTexture& sourceTexture, const BitmapTexture* contentTexture, const FilterOperation&, int pass);
-#endif
void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; }
private:
- struct ClipState {
- IntRect scissorBox;
- int stencilIndex;
- ClipState(const IntRect& scissors = IntRect(), int stencil = 1)
- : scissorBox(scissors)
- , stencilIndex(stencil)
- { }
- };
-
- class ClipStack {
- public:
- ClipStack()
- : clipStateDirty(false)
- { }
-
- // Y-axis should be inverted only when painting into the window.
- enum YAxisMode {
- DefaultYAxis,
- InvertedYAxis
- };
-
- void push();
- void pop();
- void apply(GraphicsContext3D*);
- void applyIfNeeded(GraphicsContext3D*);
- inline ClipState& current() { return clipState; }
- void reset(const IntRect&, YAxisMode);
- void intersect(const IntRect&);
- void setStencilIndex(int);
- inline int getStencilIndex() const
- {
- return clipState.stencilIndex;
- }
- inline bool isCurrentScissorBoxEmpty() const
- {
- return clipState.scissorBox.isEmpty();
- }
-
- private:
- ClipState clipState;
- Vector<ClipState> clipStack;
- bool clipStateDirty;
- IntSize size;
- YAxisMode yAxisMode;
- };
-
- TextureMapperGL();
-
- void drawTexturedQuadWithProgram(TextureMapperShaderProgram*, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
- void draw(const FloatRect&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram*, GC3Denum drawingMode, Flags);
+ void drawTexturedQuadWithProgram(TextureMapperShaderProgram&, uint32_t texture, Flags, const IntSize&, const FloatRect&, const TransformationMatrix& modelViewMatrix, float opacity);
+ void draw(const FloatRect&, const TransformationMatrix& modelViewMatrix, TextureMapperShaderProgram&, GC3Denum drawingMode, Flags);
- void drawUnitRect(TextureMapperShaderProgram*, GC3Denum drawingMode);
- void drawEdgeTriangles(TextureMapperShaderProgram*);
+ void drawUnitRect(TextureMapperShaderProgram&, GC3Denum drawingMode);
+ void drawEdgeTriangles(TextureMapperShaderProgram&);
bool beginScissorClip(const TransformationMatrix&, const FloatRect&);
void bindDefaultSurface();
@@ -136,72 +92,10 @@ private:
TextureMapperGLData* m_data;
ClipStack m_clipStack;
bool m_enableEdgeDistanceAntialiasing;
-
- friend class BitmapTextureGL;
-};
-
-class BitmapTextureGL : public BitmapTexture {
-public:
- virtual IntSize size() const;
- virtual bool isValid() const;
- virtual bool canReuseWith(const IntSize& contentsSize, Flags = 0);
- virtual void didReset();
- void bind(TextureMapperGL*);
- void initializeStencil();
- void initializeDepthBuffer();
- ~BitmapTextureGL();
- virtual uint32_t id() const { return m_id; }
- uint32_t textureTarget() const { return GraphicsContext3D::TEXTURE_2D; }
- IntSize textureSize() const { return m_textureSize; }
- void updateContents(Image*, const IntRect&, const IntPoint&, UpdateContentsFlag);
- virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag);
- virtual bool isBackedByOpenGL() const { return true; }
-
-#if ENABLE(CSS_FILTERS)
- virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&) override;
- struct FilterInfo {
- RefPtr<FilterOperation> filter;
- unsigned pass;
- RefPtr<BitmapTexture> contentTexture;
-
- FilterInfo(PassRefPtr<FilterOperation> f = 0, unsigned p = 0, PassRefPtr<BitmapTexture> t = 0)
- : filter(f)
- , pass(p)
- , contentTexture(t)
- { }
- };
- const FilterInfo* filterInfo() const { return &m_filterInfo; }
-#endif
-
-private:
- void updateContentsNoSwizzle(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel = 4, Platform3DObject glFormat = GraphicsContext3D::RGBA);
-
- Platform3DObject m_id;
- IntSize m_textureSize;
- IntRect m_dirtyRect;
- Platform3DObject m_fbo;
- Platform3DObject m_rbo;
- Platform3DObject m_depthBufferObject;
- bool m_shouldClear;
- TextureMapperGL::ClipStack m_clipStack;
- RefPtr<GraphicsContext3D> m_context3D;
-
- explicit BitmapTextureGL(TextureMapperGL*);
- BitmapTextureGL();
-
- void clearIfNeeded();
- void createFboIfNeeded();
-
-#if ENABLE(CSS_FILTERS)
- FilterInfo m_filterInfo;
-#endif
-
- friend class TextureMapperGL;
};
-BitmapTextureGL* toBitmapTextureGL(BitmapTexture*);
+} // namespace WebCore
-}
-#endif
+#endif // USE(TEXTURE_MAPPER_GL)
-#endif
+#endif // TextureMapperGL_h