2 Copyright (C) 2010 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 #include "texmap/TextureMapper.h"
22 #ifndef TextureMapperQt_h
23 #define TextureMapperQt_h
27 class BitmapTextureQt : public BitmapTexture {
28 friend class TextureMapperQt;
31 ~BitmapTextureQt() { destroy(); }
32 virtual void destroy();
33 virtual IntSize size() const { return IntSize(m_pixmap.width(), m_pixmap.height()); }
34 virtual void reset(const IntSize&, bool opaque);
35 virtual PlatformGraphicsContext* beginPaint(const IntRect& dirtyRect);
36 virtual void endPaint();
37 virtual void setContentsToImage(Image*);
38 virtual bool save(const String& path);
39 virtual bool isValid() const { return !m_pixmap.isNull() || !m_image.isNull(); }
40 IntRect sourceRect() const { return IntRect(0, 0, contentSize().width(), contentSize().height()); }
42 virtual void unpack();
43 virtual bool isPacked() const { return m_isPacked; }
45 QPainter* painter() { return &m_painter; }
54 class TextureMapperQt : public TextureMapper {
58 virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture);
59 virtual void bindSurface(BitmapTexture* surface);
60 virtual void beginClip(const TransformationMatrix&, const FloatRect&);
61 virtual void endClip();
62 virtual void setGraphicsContext(GraphicsContext*);
63 virtual GraphicsContext* graphicsContext();
64 virtual bool allowSurfaceForRoot() const { return false; }
65 virtual PassRefPtr<BitmapTexture> createTexture();
66 virtual IntSize viewportSize() const;
67 virtual void beginPainting();
68 virtual void endPainting();
70 static void initialize(QPainter* painter)
72 painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, false);
75 static PassOwnPtr<TextureMapper> create() { return adoptPtr(new TextureMapperQt); }
77 inline QPainter* currentPainter() { return m_currentSurface ? m_currentSurface->painter() : m_painter; }
80 GraphicsContext* m_context;
81 RefPtr<BitmapTextureQt> m_currentSurface;