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.
21 #include "TextureMapperImageBuffer.h"
23 #include "BitmapTexturePool.h"
24 #include "GraphicsLayer.h"
25 #include "NotImplemented.h"
27 #if USE(TEXTURE_MAPPER)
30 static const int s_maximumAllowedImageBufferDimension = 4096;
32 TextureMapperImageBuffer::TextureMapperImageBuffer()
33 : TextureMapper(SoftwareMode)
35 m_texturePool = std::make_unique<BitmapTexturePool>();
38 IntSize TextureMapperImageBuffer::maxTextureSize() const
40 return IntSize(s_maximumAllowedImageBufferDimension, s_maximumAllowedImageBufferDimension);
43 void TextureMapperImageBuffer::beginClip(const TransformationMatrix& matrix, const FloatRect& rect)
45 GraphicsContext* context = currentContext();
48 #if ENABLE(3D_TRANSFORMS)
49 TransformationMatrix previousTransform = context->get3DTransform();
51 AffineTransform previousTransform = context->getCTM();
55 #if ENABLE(3D_TRANSFORMS)
56 context->concat3DTransform(matrix);
58 context->concatCTM(matrix.toAffineTransform());
63 #if ENABLE(3D_TRANSFORMS)
64 context->set3DTransform(previousTransform);
66 context->setCTM(previousTransform);
70 void TextureMapperImageBuffer::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, unsigned /* exposedEdges */)
72 GraphicsContext* context = currentContext();
76 const BitmapTextureImageBuffer& textureImageBuffer = static_cast<const BitmapTextureImageBuffer&>(texture);
77 ImageBuffer* image = textureImageBuffer.image();
79 context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
80 context->setAlpha(opacity);
81 #if ENABLE(3D_TRANSFORMS)
82 context->concat3DTransform(matrix);
84 context->concatCTM(matrix.toAffineTransform());
86 context->drawImageBuffer(image, ColorSpaceDeviceRGB, targetRect);
90 void TextureMapperImageBuffer::drawSolidColor(const FloatRect& rect, const TransformationMatrix& matrix, const Color& color)
92 GraphicsContext* context = currentContext();
97 context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
98 #if ENABLE(3D_TRANSFORMS)
99 context->concat3DTransform(matrix);
101 context->concatCTM(matrix.toAffineTransform());
104 context->fillRect(rect, color, ColorSpaceDeviceRGB);
108 void TextureMapperImageBuffer::drawBorder(const Color&, float /* borderWidth */, const FloatRect&, const TransformationMatrix&)
113 void TextureMapperImageBuffer::drawNumber(int /* number */, const Color&, const FloatPoint&, const TransformationMatrix&)
118 PassRefPtr<BitmapTexture> BitmapTextureImageBuffer::applyFilters(TextureMapper*, const FilterOperations&)
120 ASSERT_NOT_REACHED();