Diff
Modified: trunk/Source/WebCore/ChangeLog (182100 => 182101)
--- trunk/Source/WebCore/ChangeLog 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/ChangeLog 2015-03-28 03:15:07 UTC (rev 182101)
@@ -1,3 +1,74 @@
+2015-03-27 Gwang Yoon Hwang <[email protected]>
+
+ [TexMap] Seperate BitmapTexture related classes implementations from TextureMapper
+ https://bugs.webkit.org/show_bug.cgi?id=142386
+
+ Reviewed by Žan Doberšek.
+
+ TextureMapper and TextureMapperGL are bloated and tightly coupled with
+ BitmapTexture. We should move these classes to seperated file of their own.
+ Also, this patch removes friend relationship from TextureMapperGL and its
+ subsidiary classes.
+
+ The main purpose of this refactoring is to expose BitmapTexturePool to
+ renderers of platformlayers like Video and Canvas. By doing this, each
+ renderer can acquire textures from the global texture pool to paint
+ their contents directly.
+
+ No new tests needed.
+
+ * PlatformEfl.cmake:
+ * PlatformGTK.cmake:
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+ Include BitmapTextureGL and BitmapTexturePool explicitly
+
+ * platform/graphics/texmap/BitmapTexture.cpp: Added.
+ * platform/graphics/texmap/BitmapTexture.h: Added.
+ (WebCore::BitmapTexture::updateContents):
+ Exclude BitmapTexture class from TextureMapper
+
+ * platform/graphics/texmap/BitmapTextureGL.cpp: Added.
+ * platform/graphics/texmap/BitmapTextureGL.h: Added.
+ Exclude BitmapTextureGL class from TextureMapperGL
+ (WebCore::BitmapTextureGL::clipStack): Added.
+ Add the getter for clipStack for TextureMapperGL
+ (WebCore::BitmapTextureGL::Bind): Deleted.
+ (WebCore::BitmapTextureGL::BindAsSurface): Added.
+ Bind used TextureMapperGL's internal data directly to compute projection matrix as a friend class,
+ However, TextureMapperGL can compute projection matrix itself after binding job, so this
+ friend ship is not needed. Also, this patch renames Bind to BindAsSurface to remove ambiguity.
+
+ * platform/graphics/texmap/BitmapTextureImageBuffer.cpp: Added.
+ * platform/graphics/texmap/BitmapTextureImageBuffer.h: Added.
+ Exclude BitmapTextureImageBuffer class from TextureMapperImageBuffer
+
+ * platform/graphics/texmap/BitmapTexturePool.cpp: Added.
+ * platform/graphics/texmap/BitmapTexturePool.h: Added.
+ Exclude BitmapTexturePool class from TextureMapperGL
+ (WebCore::BitmapTexturePool::acquireTexture):
+ Modified to use passed GraphicsContext3D instead of TextureMapperGL to remove redundant coupling
+
+ * platform/graphics/texmap/TextureMapper.cpp:
+ * platform/graphics/texmap/TextureMapper.h:
+ Remove BitmapTexturePool and BitmapTexture from its implementation.
+
+ * platform/graphics/texmap/TextureMapperGL.cpp:
+ * platform/graphics/texmap/TextureMapperGL.h:
+ Remove BitmapTextureGL from its implementation.
+ (WebCore::TextureMapperGL::TextureMapperGL):
+ (WebCore::TextureMapperGL::clipStack):
+ (WebCore::TextureMapperGL::bindSurface):
+ (WebCore::TextureMapperGL::currentSurface):
+ Add a getter of the current surface for filtering operation in BitmapTextureGL.
+ It would be clear to move filtering operation from BitmapTextureGL to TextureMapperGL later.
+
+ (WebCore::TextureMapperGL::ClipStack):
+ Move inner class declaration to public.
+
+ * platform/graphics/texmap/TextureMapperImageBuffer.cpp:
+ * platform/graphics/texmap/TextureMapperImageBuffer.h:
+ Remove BitmapTextureImageBuffer from its implementation.
+
2015-03-27 Tim Horton <[email protected]>
WebProcess started by editable WKWebView spends 15% of its initialization time loading DataDetectors
Modified: trunk/Source/WebCore/PlatformEfl.cmake (182100 => 182101)
--- trunk/Source/WebCore/PlatformEfl.cmake 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/PlatformEfl.cmake 2015-03-28 03:15:07 UTC (rev 182101)
@@ -179,6 +179,10 @@
platform/graphics/surfaces/glx/X11Helper.cpp
+ platform/graphics/texmap/BitmapTexture.cpp
+ platform/graphics/texmap/BitmapTextureGL.cpp
+ platform/graphics/texmap/BitmapTextureImageBuffer.cpp
+ platform/graphics/texmap/BitmapTexturePool.cpp
platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
platform/graphics/texmap/TextureMapperGL.cpp
platform/graphics/texmap/TextureMapperShaderProgram.cpp
Modified: trunk/Source/WebCore/PlatformGTK.cmake (182100 => 182101)
--- trunk/Source/WebCore/PlatformGTK.cmake 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/PlatformGTK.cmake 2015-03-28 03:15:07 UTC (rev 182101)
@@ -382,8 +382,13 @@
"${WEBCORE_DIR}/platform/graphics/texmap"
)
list(APPEND WebCore_SOURCES
+ platform/graphics/texmap/BitmapTexture.cpp
+ platform/graphics/texmap/BitmapTextureGL.cpp
+ platform/graphics/texmap/BitmapTextureImageBuffer.cpp
+ platform/graphics/texmap/BitmapTexturePool.cpp
platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
platform/graphics/texmap/TextureMapperGL.cpp
+ platform/graphics/texmap/TextureMapperImageBuffer.cpp
platform/graphics/texmap/TextureMapperShaderProgram.cpp
)
endif ()
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (182100 => 182101)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -45,6 +45,8 @@
#include <gst/video/gstvideometa.h>
#if GST_CHECK_VERSION(1, 1, 0) && USE(TEXTURE_MAPPER_GL)
+#include "BitmapTextureGL.h"
+#include "BitmapTexturePool.h"
#include "TextureMapperGL.h"
#endif
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BitmapTexture.h"
+
+#include "GraphicsLayer.h"
+#include "ImageBuffer.h"
+#include "TextureMapper.h"
+
+namespace WebCore {
+
+void BitmapTexture::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)
+{
+ std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(targetRect.size());
+ GraphicsContext* context = imageBuffer->context();
+ context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality());
+ context->setTextDrawingMode(textureMapper->textDrawingMode());
+
+ IntRect sourceRect(targetRect);
+ sourceRect.setLocation(offset);
+ context->translate(-offset.x(), -offset.y());
+ sourceLayer->paintGraphicsLayerContents(*context, sourceRect);
+
+ RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
+
+ updateContents(image.get(), targetRect, IntPoint(), updateContentsFlag);
+}
+
+} // namespace
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.h (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexture.h 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BitmapTexture_h
+#define BitmapTexture_h
+
+#if USE(OPENGL_ES_2)
+#define TEXMAP_OPENGL_ES_2
+#endif
+
+#include "IntPoint.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class FilterOperations;
+class GraphicsLayer;
+class Image;
+class TextureMapper;
+
+// A 2D texture that can be the target of software or GL rendering.
+class BitmapTexture : public RefCounted<BitmapTexture> {
+public:
+ enum Flag {
+ NoFlag = 0,
+ SupportsAlpha = 0x01
+ };
+
+ enum UpdateContentsFlag {
+ UpdateCanModifyOriginalImageData,
+ UpdateCannotModifyOriginalImageData
+ };
+
+ typedef unsigned Flags;
+
+ BitmapTexture()
+ : m_flags(0)
+ {
+ }
+
+ virtual ~BitmapTexture() { }
+ virtual bool isBackedByOpenGL() const { return false; }
+
+ virtual IntSize size() const = 0;
+ virtual void updateContents(Image*, const IntRect&, const IntPoint& offset, UpdateContentsFlag) = 0;
+ virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag);
+ virtual void updateContents(const void*, const IntRect& target, const IntPoint& offset, int bytesPerLine, UpdateContentsFlag) = 0;
+ virtual bool isValid() const = 0;
+ inline Flags flags() const { return m_flags; }
+
+ virtual int bpp() const { return 32; }
+ virtual bool canReuseWith(const IntSize& /* contentsSize */, Flags = 0) { return false; }
+ void reset(const IntSize& size, Flags flags = 0)
+ {
+ m_flags = flags;
+ m_contentSize = size;
+ didReset();
+ }
+ virtual void didReset() { }
+
+ inline IntSize contentSize() const { return m_contentSize; }
+ inline int numberOfBytes() const { return size().width() * size().height() * bpp() >> 3; }
+ inline bool isOpaque() const { return !(m_flags & SupportsAlpha); }
+
+ virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&) { return this; }
+
+protected:
+ IntSize m_contentSize;
+
+private:
+ Flags m_flags;
+};
+
+}
+
+#endif // BitmapTexture_h
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,379 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2012 Igalia S.L.
+ Copyright (C) 2012 Adobe Systems Incorporated
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "BitmapTextureGL.h"
+
+#include "Extensions3D.h"
+#include "FilterOperations.h"
+#include "GraphicsContext.h"
+#include "Image.h"
+#include "LengthFunctions.h"
+#include "NotImplemented.h"
+#include "TextureMapperShaderProgram.h"
+#include "Timer.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/TemporaryChange.h>
+
+#if USE(CAIRO)
+#include "CairoUtilities.h"
+#include "RefPtrCairo.h"
+#include <cairo.h>
+#include <wtf/text/CString.h>
+#endif
+
+#if !USE(TEXMAP_OPENGL_ES_2)
+// FIXME: Move to Extensions3D.h.
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#endif
+
+namespace WebCore {
+
+BitmapTextureGL* toBitmapTextureGL(BitmapTexture* texture)
+{
+ if (!texture || !texture->isBackedByOpenGL())
+ return 0;
+
+ return static_cast<BitmapTextureGL*>(texture);
+}
+
+BitmapTextureGL::BitmapTextureGL(PassRefPtr<GraphicsContext3D> context3D)
+ : m_id(0)
+ , m_fbo(0)
+ , m_rbo(0)
+ , m_depthBufferObject(0)
+ , m_shouldClear(true)
+ , m_context3D(context3D)
+{
+}
+
+bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags)
+{
+ return contentsSize == m_textureSize;
+}
+
+#if OS(DARWIN)
+#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+#else
+#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GraphicsContext3D::UNSIGNED_BYTE
+#endif
+
+static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride = 0)
+{
+ stride = stride ? stride : rect.width();
+ for (int y = rect.y(); y < rect.maxY(); ++y) {
+ uint32_t* p = data + y * stride;
+ for (int x = rect.x(); x < rect.maxX(); ++x)
+ p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
+ }
+}
+
+// If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
+// internal and external formats need to be BGRA
+static bool driverSupportsExternalTextureBGRA(GraphicsContext3D* context)
+{
+ if (context->isGLES2Compliant()) {
+ static bool supportsExternalTextureBGRA = context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888");
+ return supportsExternalTextureBGRA;
+ }
+
+ return true;
+}
+
+static bool driverSupportsSubImage(GraphicsContext3D* context)
+{
+ if (context->isGLES2Compliant()) {
+ static bool supportsSubImage = context->getExtensions()->supports("GL_EXT_unpack_subimage");
+ return supportsSubImage;
+ }
+
+ return true;
+}
+
+void BitmapTextureGL::didReset()
+{
+ if (!m_id)
+ m_id = m_context3D->createTexture();
+
+ m_shouldClear = true;
+ if (m_textureSize == contentSize())
+ return;
+
+
+ m_textureSize = contentSize();
+ m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+ m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
+
+ Platform3DObject internalFormat = GraphicsContext3D::RGBA;
+ Platform3DObject externalFormat = GraphicsContext3D::BGRA;
+ if (m_context3D->isGLES2Compliant()) {
+ if (driverSupportsExternalTextureBGRA(m_context3D.get()))
+ internalFormat = GraphicsContext3D::BGRA;
+ else
+ externalFormat = GraphicsContext3D::RGBA;
+ }
+
+ m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, internalFormat, m_textureSize.width(), m_textureSize.height(), 0, externalFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
+}
+
+void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat)
+{
+ m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
+ // For ES drivers that don't support sub-images.
+ if (driverSupportsSubImage(m_context3D.get())) {
+ // Use the OpenGL sub-image extension, now that we know it's available.
+ m_context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel);
+ m_context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y());
+ m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
+ }
+
+ m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, srcData);
+
+ // For ES drivers that don't support sub-images.
+ if (driverSupportsSubImage(m_context3D.get())) {
+ m_context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ m_context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ }
+}
+
+void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag updateContentsFlag)
+{
+ Platform3DObject glFormat = GraphicsContext3D::RGBA;
+ m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
+
+ const unsigned bytesPerPixel = 4;
+ char* data = ""
+ Vector<char> temporaryData;
+ IntPoint adjustedSourceOffset = sourceOffset;
+
+ // Texture upload requires subimage buffer if driver doesn't support subimage and we don't have full image upload.
+ bool requireSubImageBuffer = !driverSupportsSubImage(m_context3D.get())
+ && !(bytesPerLine == static_cast<int>(targetRect.width() * bytesPerPixel) && adjustedSourceOffset == IntPoint::zero());
+
+ // prepare temporaryData if necessary
+ if ((!driverSupportsExternalTextureBGRA(m_context3D.get()) && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
+ temporaryData.resize(targetRect.width() * targetRect.height() * bytesPerPixel);
+ data = ""
+ const char* bits = static_cast<const char*>(srcData);
+ const char* src = "" + sourceOffset.y() * bytesPerLine + sourceOffset.x() * bytesPerPixel;
+ char* dst = data;
+ const int targetBytesPerLine = targetRect.width() * bytesPerPixel;
+ for (int y = 0; y < targetRect.height(); ++y) {
+ memcpy(dst, src, targetBytesPerLine);
+ src += bytesPerLine;
+ dst += targetBytesPerLine;
+ }
+
+ bytesPerLine = targetBytesPerLine;
+ adjustedSourceOffset = IntPoint(0, 0);
+ }
+
+ if (driverSupportsExternalTextureBGRA(m_context3D.get()))
+ glFormat = GraphicsContext3D::BGRA;
+ else
+ swizzleBGRAToRGBA(reinterpret_cast_ptr<uint32_t*>(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
+
+ updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, glFormat);
+}
+
+void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)
+{
+ if (!image)
+ return;
+ NativeImagePtr frameImage = image->nativeImageForCurrentFrame();
+ if (!frameImage)
+ return;
+
+ int bytesPerLine;
+ const char* imageData;
+
+#if USE(CAIRO)
+ cairo_surface_t* surface = frameImage.get();
+ imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
+ bytesPerLine = cairo_image_surface_get_stride(surface);
+#endif
+
+ updateContents(imageData, targetRect, offset, bytesPerLine, updateContentsFlag);
+}
+
+static unsigned getPassesRequiredForFilter(FilterOperation::OperationType type)
+{
+ switch (type) {
+ case FilterOperation::GRAYSCALE:
+ case FilterOperation::SEPIA:
+ case FilterOperation::SATURATE:
+ case FilterOperation::HUE_ROTATE:
+ case FilterOperation::INVERT:
+ case FilterOperation::BRIGHTNESS:
+ case FilterOperation::CONTRAST:
+ case FilterOperation::OPACITY:
+ return 1;
+ case FilterOperation::BLUR:
+ case FilterOperation::DROP_SHADOW:
+ // We use two-passes (vertical+horizontal) for blur and drop-shadow.
+ return 2;
+ default:
+ return 0;
+ }
+}
+
+PassRefPtr<BitmapTexture> BitmapTextureGL::applyFilters(TextureMapper* textureMapper, const FilterOperations& filters)
+{
+ if (filters.isEmpty())
+ return this;
+
+ TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
+ RefPtr<BitmapTexture> previousSurface = texmapGL->currentSurface();
+ RefPtr<BitmapTexture> resultSurface = this;
+ RefPtr<BitmapTexture> intermediateSurface;
+ RefPtr<BitmapTexture> spareSurface;
+
+ m_filterInfo = FilterInfo();
+
+ for (size_t i = 0; i < filters.size(); ++i) {
+ RefPtr<FilterOperation> filter = filters.operations()[i];
+ ASSERT(filter);
+
+ int numPasses = getPassesRequiredForFilter(filter->type());
+ for (int j = 0; j < numPasses; ++j) {
+ bool last = (i == filters.size() - 1) && (j == numPasses - 1);
+ if (!last) {
+ if (!intermediateSurface)
+ intermediateSurface = texmapGL->acquireTextureFromPool(contentSize());
+ texmapGL->bindSurface(intermediateSurface.get());
+ }
+
+ if (last) {
+ toBitmapTextureGL(resultSurface.get())->m_filterInfo = BitmapTextureGL::FilterInfo(filter, j, spareSurface);
+ break;
+ }
+
+ texmapGL->drawFiltered(*resultSurface.get(), spareSurface.get(), *filter, j);
+ if (!j && filter->type() == FilterOperation::DROP_SHADOW) {
+ spareSurface = resultSurface;
+ resultSurface.clear();
+ }
+ std::swap(resultSurface, intermediateSurface);
+ }
+ }
+
+ texmapGL->bindSurface(previousSurface.get());
+ return resultSurface;
+}
+
+void BitmapTextureGL::initializeStencil()
+{
+ if (m_rbo)
+ return;
+
+ m_rbo = m_context3D->createRenderbuffer();
+ m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_rbo);
+#ifdef TEXMAP_OPENGL_ES_2
+ m_context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_textureSize.width(), m_textureSize.height());
+#else
+ m_context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_STENCIL, m_textureSize.width(), m_textureSize.height());
+#endif
+ m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0);
+ m_context3D->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_rbo);
+ m_context3D->clearStencil(0);
+ m_context3D->clear(GraphicsContext3D::STENCIL_BUFFER_BIT);
+}
+
+void BitmapTextureGL::initializeDepthBuffer()
+{
+ if (m_depthBufferObject)
+ return;
+
+ m_depthBufferObject = m_context3D->createRenderbuffer();
+ m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBufferObject);
+ m_context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, m_textureSize.width(), m_textureSize.height());
+ m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0);
+ m_context3D->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBufferObject);
+}
+
+void BitmapTextureGL::clearIfNeeded()
+{
+ if (!m_shouldClear)
+ return;
+
+ m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), TextureMapperGL::ClipStack::DefaultYAxis);
+ m_clipStack.applyIfNeeded(m_context3D.get());
+ m_context3D->clearColor(0, 0, 0, 0);
+ m_context3D->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
+ m_shouldClear = false;
+}
+
+void BitmapTextureGL::createFboIfNeeded()
+{
+ if (m_fbo)
+ return;
+
+ m_fbo = m_context3D->createFramebuffer();
+ m_context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+ m_context3D->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, id(), 0);
+ m_shouldClear = true;
+}
+
+void BitmapTextureGL::bindAsSurface(GraphicsContext3D* context3D)
+{
+ context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+ createFboIfNeeded();
+ context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+ context3D->viewport(0, 0, m_textureSize.width(), m_textureSize.height());
+ clearIfNeeded();
+ m_clipStack.apply(m_context3D.get());
+}
+
+BitmapTextureGL::~BitmapTextureGL()
+{
+ if (m_id)
+ m_context3D->deleteTexture(m_id);
+
+ if (m_fbo)
+ m_context3D->deleteFramebuffer(m_fbo);
+
+ if (m_rbo)
+ m_context3D->deleteRenderbuffer(m_rbo);
+
+ if (m_depthBufferObject)
+ m_context3D->deleteRenderbuffer(m_depthBufferObject);
+}
+
+bool BitmapTextureGL::isValid() const
+{
+ return m_id;
+}
+
+IntSize BitmapTextureGL::size() const
+{
+ return m_textureSize;
+}
+
+}; // namespace WebCore
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureGL.h 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,95 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2014 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
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef BitmapTextureGL_h
+#define BitmapTextureGL_h
+
+#include "BitmapTexture.h"
+#include "FilterOperation.h"
+#include "GraphicsContext3D.h"
+#include "IntSize.h"
+#include "TextureMapperGL.h"
+
+namespace WebCore {
+
+class TextureMapper;
+class TextureMapperGL;
+class FilterOperation;
+
+class BitmapTextureGL : public BitmapTexture {
+public:
+ BitmapTextureGL(PassRefPtr<GraphicsContext3D>);
+
+ virtual IntSize size() const;
+ virtual bool isValid() const;
+ virtual bool canReuseWith(const IntSize& contentsSize, Flags = 0);
+ virtual void didReset();
+ void bindAsSurface(GraphicsContext3D*);
+ 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);
+ void updateContentsNoSwizzle(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel = 4, Platform3DObject glFormat = GraphicsContext3D::RGBA);
+ virtual bool isBackedByOpenGL() const { return true; }
+
+ 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; }
+ TextureMapperGL::ClipStack& clipStack() { return m_clipStack; }
+
+private:
+
+ 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;
+
+ BitmapTextureGL();
+
+ void clearIfNeeded();
+ void createFboIfNeeded();
+
+ FilterInfo m_filterInfo;
+};
+
+BitmapTextureGL* toBitmapTextureGL(BitmapTexture*);
+
+}
+
+#endif // BitmapTextureGL_h
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.cpp (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BitmapTextureImageBuffer.h"
+
+#include "GraphicsLayer.h"
+
+namespace WebCore {
+
+void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag)
+{
+#if PLATFORM(CAIRO)
+ RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data()),
+ CAIRO_FORMAT_ARGB32, targetRect.width(), targetRect.height(), bytesPerLine));
+ m_image->context()->platformContext()->drawSurfaceToContext(surface.get(), targetRect,
+ IntRect(sourceOffset, targetRect.size()), m_image->context());
+#else
+ UNUSED_PARAM(data);
+ UNUSED_PARAM(targetRect);
+ UNUSED_PARAM(sourceOffset);
+ UNUSED_PARAM(bytesPerLine);
+#endif
+}
+
+void BitmapTextureImageBuffer::updateContents(TextureMapper*, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& sourceOffset, UpdateContentsFlag)
+{
+ GraphicsContext* context = m_image->context();
+
+ context->clearRect(targetRect);
+
+ IntRect sourceRect(targetRect);
+ sourceRect.setLocation(sourceOffset);
+ context->save();
+ context->clip(targetRect);
+ context->translate(targetRect.x() - sourceOffset.x(), targetRect.y() - sourceOffset.y());
+ sourceLayer->paintGraphicsLayerContents(*context, sourceRect);
+ context->restore();
+}
+
+void BitmapTextureImageBuffer::didReset()
+{
+ m_image = ImageBuffer::create(contentSize());
+}
+
+void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag)
+{
+ m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, IntRect(offset, targetRect.size()), CompositeCopy);
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.h (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTextureImageBuffer.h 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BitmapTextureImageBuffer_h
+#define BitmapTextureImageBuffer_h
+
+#include "BitmapTexture.h"
+#include "ImageBuffer.h"
+#include "IntRect.h"
+#include "IntSize.h"
+
+namespace WebCore {
+
+class GraphicsContext;
+
+class BitmapTextureImageBuffer : public BitmapTexture {
+public:
+ static PassRefPtr<BitmapTexture> create() { return adoptRef(new BitmapTextureImageBuffer); }
+ virtual IntSize size() const { return m_image->internalSize(); }
+ virtual void didReset();
+ virtual bool isValid() const { return m_image.get(); }
+ inline GraphicsContext* graphicsContext() { return m_image ? m_image->context() : 0; }
+ virtual void updateContents(Image*, const IntRect&, const IntPoint&, UpdateContentsFlag);
+ virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag);
+ virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag);
+ PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&);
+ ImageBuffer* image() const { return m_image.get(); }
+
+private:
+ BitmapTextureImageBuffer() { }
+ std::unique_ptr<ImageBuffer> m_image;
+};
+
+}
+
+#endif // BitmapTextureImageBuffer_h
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "BitmapTexturePool.h"
+
+#if USE(TEXTURE_MAPPER_GL)
+#include "BitmapTextureGL.h"
+#include "GLContext.h"
+#else
+#include "BitmapTextureImageBuffer.h"
+#endif
+
+namespace WebCore {
+
+const double s_releaseUnusedSecondsTolerance = 3;
+const double s_releaseUnusedTexturesTimerInterval = 0.5;
+
+BitmapTexturePool::BitmapTexturePool()
+ : m_releaseUnusedTexturesTimer(*this, &BitmapTexturePool::releaseUnusedTexturesTimerFired)
+{
+}
+
+#if USE(TEXTURE_MAPPER_GL)
+BitmapTexturePool::BitmapTexturePool(PassRefPtr<GraphicsContext3D> context)
+ : m_context3D(context)
+ , m_releaseUnusedTexturesTimer(*this, &BitmapTexturePool::releaseUnusedTexturesTimerFired)
+{
+}
+#endif
+
+void BitmapTexturePool::scheduleReleaseUnusedTextures()
+{
+ if (m_releaseUnusedTexturesTimer.isActive())
+ m_releaseUnusedTexturesTimer.stop();
+
+ m_releaseUnusedTexturesTimer.startOneShot(s_releaseUnusedTexturesTimerInterval);
+}
+
+void BitmapTexturePool::releaseUnusedTexturesTimerFired()
+{
+ if (m_textures.isEmpty())
+ return;
+
+ // Delete entries, which have been unused in s_releaseUnusedSecondsTolerance.
+ std::sort(m_textures.begin(), m_textures.end(), BitmapTexturePoolEntry::compareTimeLastUsed);
+
+ double minUsedTime = monotonicallyIncreasingTime() - s_releaseUnusedSecondsTolerance;
+ for (size_t i = 0; i < m_textures.size(); ++i) {
+ if (m_textures[i].m_timeLastUsed < minUsedTime) {
+ m_textures.remove(i, m_textures.size() - i);
+ break;
+ }
+ }
+}
+
+PassRefPtr<BitmapTexture> BitmapTexturePool::acquireTexture(const IntSize& size)
+{
+ BitmapTexturePoolEntry* selectedEntry = 0;
+ for (auto& entry : m_textures) {
+ // If the surface has only one reference (the one in m_textures), we can safely reuse it.
+ if (entry.m_texture->refCount() > 1)
+ continue;
+
+ if (entry.m_texture->canReuseWith(size)) {
+ selectedEntry = &entry;
+ break;
+ }
+ }
+
+ if (!selectedEntry) {
+ m_textures.append(BitmapTexturePoolEntry(createTexture()));
+ selectedEntry = &m_textures.last();
+ }
+
+ scheduleReleaseUnusedTextures();
+ selectedEntry->markUsed();
+ return selectedEntry->m_texture;
+}
+
+PassRefPtr<BitmapTexture> BitmapTexturePool::createTexture()
+{
+#if USE(TEXTURE_MAPPER_GL)
+ BitmapTextureGL* texture = new BitmapTextureGL(m_context3D);
+ return adoptRef(texture);
+#else
+ return BitmapTextureImageBuffer::create();
+#endif
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h (0 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h 2015-03-28 03:15:07 UTC (rev 182101)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef BitmapTexturePool_h
+#define BitmapTexturePool_h
+
+#if USE(OPENGL_ES_2)
+#define TEXMAP_OPENGL_ES_2
+#endif
+
+#include "BitmapTexture.h"
+#include "IntRect.h"
+#include "IntSize.h"
+#include "Timer.h"
+#include <wtf/CurrentTime.h>
+
+#if USE(TEXTURE_MAPPER_GL)
+#include "GraphicsContext3D.h"
+#endif
+
+namespace WebCore {
+
+class TextureMapper;
+
+struct BitmapTexturePoolEntry {
+ explicit BitmapTexturePoolEntry(PassRefPtr<BitmapTexture> texture)
+ : m_texture(texture)
+ { }
+ inline void markUsed() { m_timeLastUsed = monotonicallyIncreasingTime(); }
+ static bool compareTimeLastUsed(const BitmapTexturePoolEntry& a, const BitmapTexturePoolEntry& b)
+ {
+ return a.m_timeLastUsed - b.m_timeLastUsed > 0;
+ }
+
+ RefPtr<BitmapTexture> m_texture;
+ double m_timeLastUsed;
+};
+
+class BitmapTexturePool {
+ WTF_MAKE_NONCOPYABLE(BitmapTexturePool);
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ BitmapTexturePool();
+#if USE(TEXTURE_MAPPER_GL)
+ explicit BitmapTexturePool(PassRefPtr<GraphicsContext3D>);
+#endif
+
+ PassRefPtr<BitmapTexture> acquireTexture(const IntSize&);
+
+private:
+ void scheduleReleaseUnusedTextures();
+ void releaseUnusedTexturesTimerFired();
+ PassRefPtr<BitmapTexture> createTexture();
+
+#if USE(TEXTURE_MAPPER_GL)
+ RefPtr<GraphicsContext3D> m_context3D;
+#endif
+
+ Vector<BitmapTexturePoolEntry> m_textures;
+ Timer m_releaseUnusedTexturesTimer;
+};
+
+}
+
+#endif // BitmapTexturePool_h
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp (182100 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -20,6 +20,7 @@
#include "config.h"
#include "TextureMapper.h"
+#include "BitmapTexturePool.h"
#include "FilterOperations.h"
#include "GraphicsLayer.h"
#include "TextureMapperImageBuffer.h"
@@ -30,98 +31,9 @@
namespace WebCore {
-struct BitmapTexturePoolEntry {
- explicit BitmapTexturePoolEntry(PassRefPtr<BitmapTexture> texture)
- : m_texture(texture)
- { }
- inline void markUsed() { m_timeLastUsed = monotonicallyIncreasingTime(); }
- static bool compareTimeLastUsed(const BitmapTexturePoolEntry& a, const BitmapTexturePoolEntry& b)
- {
- return a.m_timeLastUsed - b.m_timeLastUsed > 0;
- }
-
- RefPtr<BitmapTexture> m_texture;
- double m_timeLastUsed;
-};
-
-class BitmapTexturePool {
- WTF_MAKE_NONCOPYABLE(BitmapTexturePool);
- WTF_MAKE_FAST_ALLOCATED;
-public:
- BitmapTexturePool();
-
- PassRefPtr<BitmapTexture> acquireTexture(const IntSize&, TextureMapper*);
-
-private:
- void scheduleReleaseUnusedTextures();
- void releaseUnusedTexturesTimerFired();
-
- Vector<BitmapTexturePoolEntry> m_textures;
- Timer m_releaseUnusedTexturesTimer;
-
- static const double s_releaseUnusedSecondsTolerance;
- static const double s_releaseUnusedTexturesTimerInterval;
-};
-
-const double BitmapTexturePool::s_releaseUnusedSecondsTolerance = 3;
-const double BitmapTexturePool::s_releaseUnusedTexturesTimerInterval = 0.5;
-
-BitmapTexturePool::BitmapTexturePool()
- : m_releaseUnusedTexturesTimer(*this, &BitmapTexturePool::releaseUnusedTexturesTimerFired)
-{ }
-
-void BitmapTexturePool::scheduleReleaseUnusedTextures()
-{
- if (m_releaseUnusedTexturesTimer.isActive())
- m_releaseUnusedTexturesTimer.stop();
-
- m_releaseUnusedTexturesTimer.startOneShot(s_releaseUnusedTexturesTimerInterval);
-}
-
-void BitmapTexturePool::releaseUnusedTexturesTimerFired()
-{
- if (m_textures.isEmpty())
- return;
-
- // Delete entries, which have been unused in s_releaseUnusedSecondsTolerance.
- std::sort(m_textures.begin(), m_textures.end(), BitmapTexturePoolEntry::compareTimeLastUsed);
-
- double minUsedTime = monotonicallyIncreasingTime() - s_releaseUnusedSecondsTolerance;
- for (size_t i = 0; i < m_textures.size(); ++i) {
- if (m_textures[i].m_timeLastUsed < minUsedTime) {
- m_textures.remove(i, m_textures.size() - i);
- break;
- }
- }
-}
-
-PassRefPtr<BitmapTexture> BitmapTexturePool::acquireTexture(const IntSize& size, TextureMapper* textureMapper)
-{
- BitmapTexturePoolEntry* selectedEntry = 0;
- for (auto& entry : m_textures) {
- // If the surface has only one reference (the one in m_textures), we can safely reuse it.
- if (entry.m_texture->refCount() > 1)
- continue;
-
- if (entry.m_texture->canReuseWith(size)) {
- selectedEntry = &entry;
- break;
- }
- }
-
- if (!selectedEntry) {
- m_textures.append(BitmapTexturePoolEntry(textureMapper->createTexture()));
- selectedEntry = &m_textures.last();
- }
-
- scheduleReleaseUnusedTextures();
- selectedEntry->markUsed();
- return selectedEntry->m_texture;
-}
-
PassRefPtr<BitmapTexture> TextureMapper::acquireTextureFromPool(const IntSize& size, const BitmapTexture::Flags flags)
{
- RefPtr<BitmapTexture> selectedTexture = m_texturePool->acquireTexture(size, this);
+ RefPtr<BitmapTexture> selectedTexture = m_texturePool->acquireTexture(size);
selectedTexture->reset(size, flags);
return selectedTexture.release();
}
@@ -137,7 +49,6 @@
: m_context(0)
, m_interpolationQuality(InterpolationDefault)
, m_textDrawingMode(TextModeFill)
- , m_texturePool(std::make_unique<BitmapTexturePool>())
, m_accelerationMode(accelerationMode)
, m_isMaskMode(false)
, m_wrapMode(StretchWrap)
@@ -146,23 +57,6 @@
TextureMapper::~TextureMapper()
{ }
-void BitmapTexture::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)
-{
- std::unique_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(targetRect.size());
- GraphicsContext* context = imageBuffer->context();
- context->setImageInterpolationQuality(textureMapper->imageInterpolationQuality());
- context->setTextDrawingMode(textureMapper->textDrawingMode());
-
- IntRect sourceRect(targetRect);
- sourceRect.setLocation(offset);
- context->translate(-offset.x(), -offset.y());
- sourceLayer->paintGraphicsLayerContents(*context, sourceRect);
-
- RefPtr<Image> image = imageBuffer->copyImage(DontCopyBackingStore);
-
- updateContents(image.get(), targetRect, IntPoint(), updateContentsFlag);
-}
-
} // namespace
#endif
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h (182100 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapper.h 2015-03-28 03:15:07 UTC (rev 182101)
@@ -22,10 +22,11 @@
#if USE(TEXTURE_MAPPER)
-#if (PLATFORM(GTK) || PLATFORM(EFL)) && USE(OPENGL_ES_2)
+#if USE(OPENGL_ES_2)
#define TEXMAP_OPENGL_ES_2
#endif
+#include "BitmapTexture.h"
#include "GraphicsContext.h"
#include "IntRect.h"
#include "IntSize.h"
@@ -43,64 +44,8 @@
class TextureMapper;
class FilterOperations;
-// A 2D texture that can be the target of software or GL rendering.
-class BitmapTexture : public RefCounted<BitmapTexture> {
-public:
- enum Flag {
- NoFlag = 0,
- SupportsAlpha = 0x01
- };
-
- enum UpdateContentsFlag {
- UpdateCanModifyOriginalImageData,
- UpdateCannotModifyOriginalImageData
- };
-
- typedef unsigned Flags;
-
- BitmapTexture()
- : m_flags(0)
- {
- }
-
- virtual ~BitmapTexture() { }
- virtual bool isBackedByOpenGL() const { return false; }
-
- virtual IntSize size() const = 0;
- virtual void updateContents(Image*, const IntRect&, const IntPoint& offset, UpdateContentsFlag) = 0;
- virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag);
- virtual void updateContents(const void*, const IntRect& target, const IntPoint& offset, int bytesPerLine, UpdateContentsFlag) = 0;
- virtual bool isValid() const = 0;
- inline Flags flags() const { return m_flags; }
-
- virtual int bpp() const { return 32; }
- virtual bool canReuseWith(const IntSize& /* contentsSize */, Flags = 0) { return false; }
- void reset(const IntSize& size, Flags flags = 0)
- {
- m_flags = flags;
- m_contentSize = size;
- didReset();
- }
- virtual void didReset() { }
-
- inline IntSize contentSize() const { return m_contentSize; }
- inline int numberOfBytes() const { return size().width() * size().height() * bpp() >> 3; }
- inline bool isOpaque() const { return !(m_flags & SupportsAlpha); }
-
- virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&) { return this; }
-
-protected:
- IntSize m_contentSize;
-
-private:
- Flags m_flags;
-};
-
-// A "context" class used to encapsulate accelerated texture mapping functions: i.e. drawing a texture
-// onto the screen or into another texture with a specified transform, opacity and mask.
class TextureMapper {
WTF_MAKE_FAST_ALLOCATED;
- friend class BitmapTexture;
public:
enum AccelerationMode { SoftwareMode, OpenGLMode };
enum PaintFlag {
@@ -164,6 +109,7 @@
protected:
GraphicsContext* m_context;
+ std::unique_ptr<BitmapTexturePool> m_texturePool;
bool isInMaskMode() const { return m_isMaskMode; }
WrapMode wrapMode() const { return m_wrapMode; }
@@ -180,7 +126,6 @@
#endif
InterpolationQuality m_interpolationQuality;
TextDrawingModeFlags m_textDrawingMode;
- std::unique_ptr<BitmapTexturePool> m_texturePool;
AccelerationMode m_accelerationMode;
bool m_isMaskMode;
TransformationMatrix m_patternTransform;
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp (182100 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -22,6 +22,8 @@
#include "config.h"
#include "TextureMapperGL.h"
+#include "BitmapTextureGL.h"
+#include "BitmapTexturePool.h"
#include "Extensions3D.h"
#include "FilterOperations.h"
#include "GraphicsContext.h"
@@ -238,25 +240,18 @@
didModifyStencil = true;
}
-BitmapTextureGL* toBitmapTextureGL(BitmapTexture* texture)
-{
- if (!texture || !texture->isBackedByOpenGL())
- return 0;
-
- return static_cast<BitmapTextureGL*>(texture);
-}
-
TextureMapperGL::TextureMapperGL()
: TextureMapper(OpenGLMode)
, m_enableEdgeDistanceAntialiasing(false)
{
m_context3D = GraphicsContext3D::createForCurrentGLContext();
m_data = new TextureMapperGLData(m_context3D.get());
+ m_texturePool = std::make_unique<BitmapTexturePool>(m_context3D);
}
TextureMapperGL::ClipStack& TextureMapperGL::clipStack()
{
- return data().currentSurface ? toBitmapTextureGL(data().currentSurface.get())->m_clipStack : m_clipStack;
+ return data().currentSurface ? toBitmapTextureGL(data().currentSurface.get())->clipStack() : m_clipStack;
}
void TextureMapperGL::beginPainting(PaintFlags flags)
@@ -391,27 +386,6 @@
}
}
-static unsigned getPassesRequiredForFilter(FilterOperation::OperationType type)
-{
- switch (type) {
- case FilterOperation::GRAYSCALE:
- case FilterOperation::SEPIA:
- case FilterOperation::SATURATE:
- case FilterOperation::HUE_ROTATE:
- case FilterOperation::INVERT:
- case FilterOperation::BRIGHTNESS:
- case FilterOperation::CONTRAST:
- case FilterOperation::OPACITY:
- return 1;
- case FilterOperation::BLUR:
- case FilterOperation::DROP_SHADOW:
- // We use two-passes (vertical+horizontal) for blur and drop-shadow.
- return 2;
- default:
- return 0;
- }
-}
-
// Create a normal distribution of 21 values between -2 and 2.
static const unsigned GaussianKernelHalfWidth = 11;
static const float GaussianKernelStep = 0.2;
@@ -681,167 +655,6 @@
m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
}
-BitmapTextureGL::BitmapTextureGL(TextureMapperGL* textureMapper)
- : m_id(0)
- , m_fbo(0)
- , m_rbo(0)
- , m_depthBufferObject(0)
- , m_shouldClear(true)
- , m_context3D(textureMapper->graphicsContext3D())
-{
-}
-
-bool BitmapTextureGL::canReuseWith(const IntSize& contentsSize, Flags)
-{
- return contentsSize == m_textureSize;
-}
-
-#if OS(DARWIN)
-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
-#else
-#define DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE GraphicsContext3D::UNSIGNED_BYTE
-#endif
-
-static void swizzleBGRAToRGBA(uint32_t* data, const IntRect& rect, int stride = 0)
-{
- stride = stride ? stride : rect.width();
- for (int y = rect.y(); y < rect.maxY(); ++y) {
- uint32_t* p = data + y * stride;
- for (int x = rect.x(); x < rect.maxX(); ++x)
- p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
- }
-}
-
-// If GL_EXT_texture_format_BGRA8888 is supported in the OpenGLES
-// internal and external formats need to be BGRA
-static bool driverSupportsExternalTextureBGRA(GraphicsContext3D* context)
-{
- if (context->isGLES2Compliant()) {
- static bool supportsExternalTextureBGRA = context->getExtensions()->supports("GL_EXT_texture_format_BGRA8888");
- return supportsExternalTextureBGRA;
- }
-
- return true;
-}
-
-static bool driverSupportsSubImage(GraphicsContext3D* context)
-{
- if (context->isGLES2Compliant()) {
- static bool supportsSubImage = context->getExtensions()->supports("GL_EXT_unpack_subimage");
- return supportsSubImage;
- }
-
- return true;
-}
-
-void BitmapTextureGL::didReset()
-{
- if (!m_id)
- m_id = m_context3D->createTexture();
-
- m_shouldClear = true;
- if (m_textureSize == contentSize())
- return;
-
-
- m_textureSize = contentSize();
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
- m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
- m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
- m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
- m_context3D->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
-
- Platform3DObject internalFormat = GraphicsContext3D::RGBA;
- Platform3DObject externalFormat = GraphicsContext3D::BGRA;
- if (m_context3D->isGLES2Compliant()) {
- if (driverSupportsExternalTextureBGRA(m_context3D.get()))
- internalFormat = GraphicsContext3D::BGRA;
- else
- externalFormat = GraphicsContext3D::RGBA;
- }
-
- m_context3D->texImage2DDirect(GraphicsContext3D::TEXTURE_2D, 0, internalFormat, m_textureSize.width(), m_textureSize.height(), 0, externalFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, 0);
-}
-
-void BitmapTextureGL::updateContentsNoSwizzle(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel, Platform3DObject glFormat)
-{
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
- if (driverSupportsSubImage(m_context3D.get())) { // For ES drivers that don't support sub-images.
- // Use the OpenGL sub-image extension, now that we know it's available.
- m_context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, bytesPerLine / bytesPerPixel);
- m_context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, sourceOffset.y());
- m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, sourceOffset.x());
- }
-
- m_context3D->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, targetRect.x(), targetRect.y(), targetRect.width(), targetRect.height(), glFormat, DEFAULT_TEXTURE_PIXEL_TRANSFER_TYPE, srcData);
-
- if (driverSupportsSubImage(m_context3D.get())) { // For ES drivers that don't support sub-images.
- m_context3D->pixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- m_context3D->pixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- m_context3D->pixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- }
-}
-
-void BitmapTextureGL::updateContents(const void* srcData, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag updateContentsFlag)
-{
- Platform3DObject glFormat = GraphicsContext3D::RGBA;
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, m_id);
-
- const unsigned bytesPerPixel = 4;
- char* data = ""
- Vector<char> temporaryData;
- IntPoint adjustedSourceOffset = sourceOffset;
-
- // Texture upload requires subimage buffer if driver doesn't support subimage and we don't have full image upload.
- bool requireSubImageBuffer = !driverSupportsSubImage(m_context3D.get())
- && !(bytesPerLine == static_cast<int>(targetRect.width() * bytesPerPixel) && adjustedSourceOffset == IntPoint::zero());
-
- // prepare temporaryData if necessary
- if ((!driverSupportsExternalTextureBGRA(m_context3D.get()) && updateContentsFlag == UpdateCannotModifyOriginalImageData) || requireSubImageBuffer) {
- temporaryData.resize(targetRect.width() * targetRect.height() * bytesPerPixel);
- data = ""
- const char* bits = static_cast<const char*>(srcData);
- const char* src = "" + sourceOffset.y() * bytesPerLine + sourceOffset.x() * bytesPerPixel;
- char* dst = data;
- const int targetBytesPerLine = targetRect.width() * bytesPerPixel;
- for (int y = 0; y < targetRect.height(); ++y) {
- memcpy(dst, src, targetBytesPerLine);
- src += bytesPerLine;
- dst += targetBytesPerLine;
- }
-
- bytesPerLine = targetBytesPerLine;
- adjustedSourceOffset = IntPoint(0, 0);
- }
-
- if (driverSupportsExternalTextureBGRA(m_context3D.get()))
- glFormat = GraphicsContext3D::BGRA;
- else
- swizzleBGRAToRGBA(reinterpret_cast_ptr<uint32_t*>(data), IntRect(adjustedSourceOffset, targetRect.size()), bytesPerLine / bytesPerPixel);
-
- updateContentsNoSwizzle(data, targetRect, adjustedSourceOffset, bytesPerLine, bytesPerPixel, glFormat);
-}
-
-void BitmapTextureGL::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag updateContentsFlag)
-{
- if (!image)
- return;
- NativeImagePtr frameImage = image->nativeImageForCurrentFrame();
- if (!frameImage)
- return;
-
- int bytesPerLine;
- const char* imageData;
-
-#if USE(CAIRO)
- cairo_surface_t* surface = frameImage.get();
- imageData = reinterpret_cast<const char*>(cairo_image_surface_get_data(surface));
- bytesPerLine = cairo_image_surface_get_stride(surface);
-#endif
-
- updateContents(imageData, targetRect, offset, bytesPerLine, updateContentsFlag);
-}
-
void TextureMapperGL::drawFiltered(const BitmapTexture& sampler, const BitmapTexture* contentTexture, const FilterOperation& filter, int pass)
{
// For standard filters, we always draw the whole texture without transformations.
@@ -854,50 +667,6 @@
drawTexturedQuadWithProgram(program.get(), static_cast<const BitmapTextureGL&>(sampler).id(), 0, IntSize(1, 1), targetRect, TransformationMatrix(), 1);
}
-PassRefPtr<BitmapTexture> BitmapTextureGL::applyFilters(TextureMapper* textureMapper, const FilterOperations& filters)
-{
- if (filters.isEmpty())
- return this;
-
- TextureMapperGL* texmapGL = static_cast<TextureMapperGL*>(textureMapper);
- RefPtr<BitmapTexture> previousSurface = texmapGL->data().currentSurface;
- RefPtr<BitmapTexture> resultSurface = this;
- RefPtr<BitmapTexture> intermediateSurface;
- RefPtr<BitmapTexture> spareSurface;
-
- m_filterInfo = FilterInfo();
-
- for (size_t i = 0; i < filters.size(); ++i) {
- RefPtr<FilterOperation> filter = filters.operations()[i];
- ASSERT(filter);
-
- int numPasses = getPassesRequiredForFilter(filter->type());
- for (int j = 0; j < numPasses; ++j) {
- bool last = (i == filters.size() - 1) && (j == numPasses - 1);
- if (!last) {
- if (!intermediateSurface)
- intermediateSurface = texmapGL->acquireTextureFromPool(contentSize());
- texmapGL->bindSurface(intermediateSurface.get());
- }
-
- if (last) {
- toBitmapTextureGL(resultSurface.get())->m_filterInfo = BitmapTextureGL::FilterInfo(filter, j, spareSurface);
- break;
- }
-
- texmapGL->drawFiltered(*resultSurface.get(), spareSurface.get(), *filter, j);
- if (!j && filter->type() == FilterOperation::DROP_SHADOW) {
- spareSurface = resultSurface;
- resultSurface.clear();
- }
- std::swap(resultSurface, intermediateSurface);
- }
- }
-
- texmapGL->bindSurface(previousSurface.get());
- return resultSurface;
-}
-
static inline TransformationMatrix createProjectionMatrix(const IntSize& size, bool mirrored)
{
const float nearValue = 9999999;
@@ -909,95 +678,6 @@
-1, mirrored ? -1 : 1, -(farValue + nearValue) / (farValue - nearValue), 1);
}
-void BitmapTextureGL::initializeStencil()
-{
- if (m_rbo)
- return;
-
- m_rbo = m_context3D->createRenderbuffer();
- m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_rbo);
-#ifdef TEXMAP_OPENGL_ES_2
- m_context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::STENCIL_INDEX8, m_textureSize.width(), m_textureSize.height());
-#else
- m_context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_STENCIL, m_textureSize.width(), m_textureSize.height());
-#endif
- m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0);
- m_context3D->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_rbo);
- m_context3D->clearStencil(0);
- m_context3D->clear(GraphicsContext3D::STENCIL_BUFFER_BIT);
-}
-
-void BitmapTextureGL::initializeDepthBuffer()
-{
- if (m_depthBufferObject)
- return;
-
- m_depthBufferObject = m_context3D->createRenderbuffer();
- m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_depthBufferObject);
- m_context3D->renderbufferStorage(GraphicsContext3D::RENDERBUFFER, GraphicsContext3D::DEPTH_COMPONENT16, m_textureSize.width(), m_textureSize.height());
- m_context3D->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, 0);
- m_context3D->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, GraphicsContext3D::RENDERBUFFER, m_depthBufferObject);
-}
-
-void BitmapTextureGL::clearIfNeeded()
-{
- if (!m_shouldClear)
- return;
-
- m_clipStack.reset(IntRect(IntPoint::zero(), m_textureSize), TextureMapperGL::ClipStack::DefaultYAxis);
- m_clipStack.applyIfNeeded(m_context3D.get());
- m_context3D->clearColor(0, 0, 0, 0);
- m_context3D->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
- m_shouldClear = false;
-}
-
-void BitmapTextureGL::createFboIfNeeded()
-{
- if (m_fbo)
- return;
-
- m_fbo = m_context3D->createFramebuffer();
- m_context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
- m_context3D->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, id(), 0);
- m_shouldClear = true;
-}
-
-void BitmapTextureGL::bind(TextureMapperGL* textureMapper)
-{
- m_context3D->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
- createFboIfNeeded();
- m_context3D->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
- m_context3D->viewport(0, 0, m_textureSize.width(), m_textureSize.height());
- clearIfNeeded();
- textureMapper->data().projectionMatrix = createProjectionMatrix(m_textureSize, true /* mirrored */);
- m_clipStack.apply(m_context3D.get());
-}
-
-BitmapTextureGL::~BitmapTextureGL()
-{
- if (m_id)
- m_context3D->deleteTexture(m_id);
-
- if (m_fbo)
- m_context3D->deleteFramebuffer(m_fbo);
-
- if (m_rbo)
- m_context3D->deleteRenderbuffer(m_rbo);
-
- if (m_depthBufferObject)
- m_context3D->deleteRenderbuffer(m_depthBufferObject);
-}
-
-bool BitmapTextureGL::isValid() const
-{
- return m_id;
-}
-
-IntSize BitmapTextureGL::size() const
-{
- return m_textureSize;
-}
-
TextureMapperGL::~TextureMapperGL()
{
delete m_data;
@@ -1020,10 +700,16 @@
return;
}
- static_cast<BitmapTextureGL*>(surface)->bind(this);
+ static_cast<BitmapTextureGL*>(surface)->bindAsSurface(m_context3D.get());
+ data().projectionMatrix = createProjectionMatrix(surface->size(), true /* mirrored */);
data().currentSurface = surface;
}
+BitmapTexture* TextureMapperGL::currentSurface()
+{
+ return data().currentSurface.get();
+}
+
bool TextureMapperGL::beginScissorClip(const TransformationMatrix& modelViewMatrix, const FloatRect& targetRect)
{
// 3D transforms are currently not supported in scissor clipping
@@ -1107,7 +793,7 @@
PassRefPtr<BitmapTexture> TextureMapperGL::createTexture()
{
- BitmapTextureGL* texture = new BitmapTextureGL(this);
+ BitmapTextureGL* texture = new BitmapTextureGL(m_context3D);
return adoptRef(texture);
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h (182100 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperGL.h 2015-03-28 03:15:07 UTC (rev 182101)
@@ -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
@@ -38,40 +39,6 @@
// An OpenGL-ES2 implementation of TextureMapper.
class TextureMapperGL : public TextureMapper {
public:
- TextureMapperGL();
- virtual ~TextureMapperGL();
-
- enum Flag {
- ShouldBlend = 0x01,
- ShouldFlipTexture = 0x02,
- ShouldUseARBTextureRect = 0x04,
- ShouldAntialias = 0x08
- };
-
- 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;
- 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;
- inline GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); }
-
- void drawFiltered(const BitmapTexture& sourceTexture, const BitmapTexture* contentTexture, const FilterOperation&, int pass);
-
- void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; }
-
-private:
struct ClipState {
IntRect scissorBox;
int stencilIndex;
@@ -118,6 +85,41 @@
YAxisMode yAxisMode;
};
+ TextureMapperGL();
+ virtual ~TextureMapperGL();
+
+ enum Flag {
+ ShouldBlend = 0x01,
+ ShouldFlipTexture = 0x02,
+ ShouldUseARBTextureRect = 0x04,
+ ShouldAntialias = 0x08
+ };
+
+ 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;
+ 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;
+ BitmapTexture* currentSurface();
+ 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;
+ inline GraphicsContext3D* graphicsContext3D() const { return m_context3D.get(); }
+
+ void drawFiltered(const BitmapTexture& sourceTexture, const BitmapTexture* contentTexture, const FilterOperation&, int pass);
+
+ void setEnableEdgeDistanceAntialiasing(bool enabled) { m_enableEdgeDistanceAntialiasing = enabled; }
+
+private:
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);
@@ -132,68 +134,10 @@
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; }
+} // namespace WebCore
- virtual PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&) override;
- struct FilterInfo {
- RefPtr<FilterOperation> filter;
- unsigned pass;
- RefPtr<BitmapTexture> contentTexture;
+#endif // USE(TEXTURE_MAPPER)
- 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; }
-
-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();
-
- FilterInfo m_filterInfo;
-
- friend class TextureMapperGL;
-};
-
-BitmapTextureGL* toBitmapTextureGL(BitmapTexture*);
-
-}
-#endif
-
-#endif
+#endif // TextureMapperGL_h
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp (182100 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -20,6 +20,7 @@
#include "config.h"
#include "TextureMapperImageBuffer.h"
+#include "BitmapTexturePool.h"
#include "GraphicsLayer.h"
#include "NotImplemented.h"
@@ -28,48 +29,12 @@
static const int s_maximumAllowedImageBufferDimension = 4096;
-void BitmapTextureImageBuffer::updateContents(const void* data, const IntRect& targetRect, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag)
+TextureMapperImageBuffer::TextureMapperImageBuffer()
+ : TextureMapper(SoftwareMode)
{
-#if PLATFORM(CAIRO)
- RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(data()),
- CAIRO_FORMAT_ARGB32,
- targetRect.width(), targetRect.height(),
- bytesPerLine));
- m_image->context()->platformContext()->drawSurfaceToContext(surface.get(), targetRect,
- IntRect(sourceOffset, targetRect.size()), m_image->context());
-#else
- UNUSED_PARAM(data);
- UNUSED_PARAM(targetRect);
- UNUSED_PARAM(sourceOffset);
- UNUSED_PARAM(bytesPerLine);
-#endif
+ m_texturePool = std::make_unique<BitmapTexturePool>();
}
-void BitmapTextureImageBuffer::updateContents(TextureMapper*, GraphicsLayer* sourceLayer, const IntRect& targetRect, const IntPoint& sourceOffset, UpdateContentsFlag)
-{
- GraphicsContext* context = m_image->context();
-
- context->clearRect(targetRect);
-
- IntRect sourceRect(targetRect);
- sourceRect.setLocation(sourceOffset);
- context->save();
- context->clip(targetRect);
- context->translate(targetRect.x() - sourceOffset.x(), targetRect.y() - sourceOffset.y());
- sourceLayer->paintGraphicsLayerContents(*context, sourceRect);
- context->restore();
-}
-
-void BitmapTextureImageBuffer::didReset()
-{
- m_image = ImageBuffer::create(contentSize());
-}
-
-void BitmapTextureImageBuffer::updateContents(Image* image, const IntRect& targetRect, const IntPoint& offset, UpdateContentsFlag)
-{
- m_image->context()->drawImage(image, ColorSpaceDeviceRGB, targetRect, IntRect(offset, targetRect.size()), CompositeCopy);
-}
-
IntSize TextureMapperImageBuffer::maxTextureSize() const
{
return IntSize(s_maximumAllowedImageBufferDimension, s_maximumAllowedImageBufferDimension);
@@ -109,7 +74,7 @@
return;
const BitmapTextureImageBuffer& textureImageBuffer = static_cast<const BitmapTextureImageBuffer&>(texture);
- ImageBuffer* image = textureImageBuffer.m_image.get();
+ ImageBuffer* image = textureImageBuffer.image();
context->save();
context->setCompositeOperation(isInMaskMode() ? CompositeDestinationIn : CompositeSourceOver);
context->setAlpha(opacity);
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h (182100 => 182101)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.h 2015-03-28 03:15:07 UTC (rev 182101)
@@ -20,37 +20,17 @@
#ifndef TextureMapperImageBuffer_h
#define TextureMapperImageBuffer_h
+#include "BitmapTextureImageBuffer.h"
#include "ImageBuffer.h"
#include "TextureMapper.h"
#if USE(TEXTURE_MAPPER)
namespace WebCore {
-class BitmapTextureImageBuffer : public BitmapTexture {
- friend class TextureMapperImageBuffer;
-public:
- static PassRefPtr<BitmapTexture> create() { return adoptRef(new BitmapTextureImageBuffer); }
- virtual IntSize size() const { return m_image->internalSize(); }
- virtual void didReset();
- virtual bool isValid() const { return m_image.get(); }
- inline GraphicsContext* graphicsContext() { return m_image ? m_image->context() : 0; }
- virtual void updateContents(Image*, const IntRect&, const IntPoint&, UpdateContentsFlag);
- virtual void updateContents(TextureMapper*, GraphicsLayer*, const IntRect& target, const IntPoint& offset, UpdateContentsFlag);
- virtual void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag);
- PassRefPtr<BitmapTexture> applyFilters(TextureMapper*, const FilterOperations&);
-
-private:
- BitmapTextureImageBuffer() { }
- std::unique_ptr<ImageBuffer> m_image;
-};
-
-
class TextureMapperImageBuffer : public TextureMapper {
WTF_MAKE_FAST_ALLOCATED;
public:
- TextureMapperImageBuffer()
- : TextureMapper(SoftwareMode)
- { }
+ TextureMapperImageBuffer();
// TextureMapper implementation
virtual void drawBorder(const Color&, float borderWidth, const FloatRect&, const TransformationMatrix&) override;
Modified: trunk/Source/WebKit2/ChangeLog (182100 => 182101)
--- trunk/Source/WebKit2/ChangeLog 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebKit2/ChangeLog 2015-03-28 03:15:07 UTC (rev 182101)
@@ -1,3 +1,22 @@
+2015-03-27 Gwang Yoon Hwang <[email protected]>
+
+ [TexMap] Seperate BitmapTexture related classes implementations from TextureMapper
+ https://bugs.webkit.org/show_bug.cgi?id=142386
+
+ Reviewed by Žan Doberšek.
+
+ TextureMapper and TextureMapperGL are bloated and tightly coupled with
+ BitmapTexture. We should move these classes to seperated file of their own.
+ Also, this patch removes friend relationship from TextureMapperGL and its
+ subsidiary classes.
+
+ The main purpose of this refactoring is to expose BitmapTexturePool to
+ renderers of platformlayers like Video and Canvas. By doing this, each
+ renderer can acquire textures from the global texture pool to paint
+ their contents directly.
+
+ * Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp: Include BitmapTextureGL.h explicitly
+
2015-03-27 Anders Carlsson <[email protected]>
Use a typedef for the WKPluginLoadClientPolicy enum
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp (182100 => 182101)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp 2015-03-28 03:09:20 UTC (rev 182100)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp 2015-03-28 03:15:07 UTC (rev 182101)
@@ -28,6 +28,7 @@
#include <WebCore/GraphicsSurfaceToken.h>
#if USE(TEXTURE_MAPPER)
+#include "BitmapTextureGL.h"
#include "TextureMapperGL.h"
#endif