[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
jamesr at google.com
jamesr at google.com
Wed Dec 22 12:43:13 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 190fec2f7d15d9c0e5f9a5bb6fb165da32bb5871
Author: jamesr at google.com <jamesr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Aug 27 20:37:19 2010 +0000
2010-08-27 James Robinson <jamesr at chromium.org>
Reviewed by Darin Fisher.
Move Texture class from p/g/chromium to p/g/gpu
https://bugs.webkit.org/show_bug.cgi?id=44783
This class and its support were developed in platform/graphics/chromium but are not chromium-specific
in any way. This patch moves them to a common location so they can be shared by all platforms.
Pure refactor, so no new tests.
* WebCore.gyp/WebCore.gyp:
* WebCore.gypi:
* platform/graphics/chromium/GLES2Canvas.cpp:
(WebCore::GLES2Canvas::drawTexturedRect):
(WebCore::GLES2Canvas::drawTexturedRectTile):
(WebCore::GLES2Canvas::createTexture):
(WebCore::GLES2Canvas::getTexture):
* platform/graphics/chromium/GLES2Canvas.h:
* platform/graphics/chromium/GLES2Texture.cpp: Removed.
* platform/graphics/chromium/GLES2Texture.h: Removed.
* platform/graphics/gpu/Texture.cpp: Added.
(WebCore::Texture::Texture):
(WebCore::Texture::~Texture):
(WebCore::convertFormat):
(WebCore::Texture::create):
(WebCore::copySubRect):
(WebCore::Texture::load):
(WebCore::Texture::bindTile):
* platform/graphics/gpu/Texture.h: Added.
(WebCore::Texture::):
(WebCore::Texture::format):
(WebCore::Texture::tiles):
* platform/graphics/gpu/TilingData.cpp: Renamed from WebCore/platform/graphics/chromium/TilingData.cpp.
(WebCore::computeNumTiles):
(WebCore::TilingData::TilingData):
(WebCore::TilingData::tileXIndexFromSrcCoord):
(WebCore::TilingData::tileYIndexFromSrcCoord):
(WebCore::TilingData::tileBounds):
(WebCore::TilingData::tileBoundsWithBorder):
(WebCore::TilingData::tileBoundsNormalized):
(WebCore::TilingData::tilePositionX):
(WebCore::TilingData::tilePositionY):
(WebCore::TilingData::tileSizeX):
(WebCore::TilingData::tileSizeY):
(WebCore::TilingData::overlappedTileIndices):
(WebCore::TilingData::intersectDrawQuad):
* platform/graphics/gpu/TilingData.h: Renamed from WebCore/platform/graphics/chromium/TilingData.h.
(WebCore::TilingData::maxTextureSize):
(WebCore::TilingData::totalSizeX):
(WebCore::TilingData::totalSizeY):
(WebCore::TilingData::numTiles):
(WebCore::TilingData::numTilesX):
(WebCore::TilingData::numTilesY):
(WebCore::TilingData::tileIndex):
(WebCore::TilingData::tileXIndex):
(WebCore::TilingData::tileYIndex):
(WebCore::TilingData::TilingData):
(WebCore::TilingData::assertTile):
* platform/graphics/skia/ImageSkia.cpp:
(WebCore::drawBitmapGLES2):
* platform/graphics/skia/PlatformContextSkia.cpp:
(WebCore::PlatformContextSkia::uploadSoftwareToHardware):
* platform/graphics/skia/PlatformContextSkia.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@66248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 8c898e0..dae300e 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,69 @@
+2010-08-27 James Robinson <jamesr at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ Move Texture class from p/g/chromium to p/g/gpu
+ https://bugs.webkit.org/show_bug.cgi?id=44783
+
+ This class and its support were developed in platform/graphics/chromium but are not chromium-specific
+ in any way. This patch moves them to a common location so they can be shared by all platforms.
+
+ Pure refactor, so no new tests.
+
+ * WebCore.gyp/WebCore.gyp:
+ * WebCore.gypi:
+ * platform/graphics/chromium/GLES2Canvas.cpp:
+ (WebCore::GLES2Canvas::drawTexturedRect):
+ (WebCore::GLES2Canvas::drawTexturedRectTile):
+ (WebCore::GLES2Canvas::createTexture):
+ (WebCore::GLES2Canvas::getTexture):
+ * platform/graphics/chromium/GLES2Canvas.h:
+ * platform/graphics/chromium/GLES2Texture.cpp: Removed.
+ * platform/graphics/chromium/GLES2Texture.h: Removed.
+ * platform/graphics/gpu/Texture.cpp: Added.
+ (WebCore::Texture::Texture):
+ (WebCore::Texture::~Texture):
+ (WebCore::convertFormat):
+ (WebCore::Texture::create):
+ (WebCore::copySubRect):
+ (WebCore::Texture::load):
+ (WebCore::Texture::bindTile):
+ * platform/graphics/gpu/Texture.h: Added.
+ (WebCore::Texture::):
+ (WebCore::Texture::format):
+ (WebCore::Texture::tiles):
+ * platform/graphics/gpu/TilingData.cpp: Renamed from WebCore/platform/graphics/chromium/TilingData.cpp.
+ (WebCore::computeNumTiles):
+ (WebCore::TilingData::TilingData):
+ (WebCore::TilingData::tileXIndexFromSrcCoord):
+ (WebCore::TilingData::tileYIndexFromSrcCoord):
+ (WebCore::TilingData::tileBounds):
+ (WebCore::TilingData::tileBoundsWithBorder):
+ (WebCore::TilingData::tileBoundsNormalized):
+ (WebCore::TilingData::tilePositionX):
+ (WebCore::TilingData::tilePositionY):
+ (WebCore::TilingData::tileSizeX):
+ (WebCore::TilingData::tileSizeY):
+ (WebCore::TilingData::overlappedTileIndices):
+ (WebCore::TilingData::intersectDrawQuad):
+ * platform/graphics/gpu/TilingData.h: Renamed from WebCore/platform/graphics/chromium/TilingData.h.
+ (WebCore::TilingData::maxTextureSize):
+ (WebCore::TilingData::totalSizeX):
+ (WebCore::TilingData::totalSizeY):
+ (WebCore::TilingData::numTiles):
+ (WebCore::TilingData::numTilesX):
+ (WebCore::TilingData::numTilesY):
+ (WebCore::TilingData::tileIndex):
+ (WebCore::TilingData::tileXIndex):
+ (WebCore::TilingData::tileYIndex):
+ (WebCore::TilingData::TilingData):
+ (WebCore::TilingData::assertTile):
+ * platform/graphics/skia/ImageSkia.cpp:
+ (WebCore::drawBitmapGLES2):
+ * platform/graphics/skia/PlatformContextSkia.cpp:
+ (WebCore::PlatformContextSkia::uploadSoftwareToHardware):
+ * platform/graphics/skia/PlatformContextSkia.h:
+
2010-08-27 David Hyatt <hyatt at apple.com>
Reviewed by Simon Fraser.
diff --git a/WebCore/WebCore.gyp/WebCore.gyp b/WebCore/WebCore.gyp/WebCore.gyp
index 25ad450..86bffda 100644
--- a/WebCore/WebCore.gyp/WebCore.gyp
+++ b/WebCore/WebCore.gyp/WebCore.gyp
@@ -138,6 +138,7 @@
'../platform/graphics',
'../platform/graphics/chromium',
'../platform/graphics/filters',
+ '../platform/graphics/gpu',
'../platform/graphics/opentype',
'../platform/graphics/skia',
'../platform/graphics/transforms',
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 46ac5a4..4cc59bb 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -2252,8 +2252,6 @@
'platform/graphics/chromium/FontUtilsChromiumWin.h',
'platform/graphics/chromium/GLES2Canvas.cpp',
'platform/graphics/chromium/GLES2Canvas.h',
- 'platform/graphics/chromium/GLES2Texture.cpp',
- 'platform/graphics/chromium/GLES2Texture.h',
'platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp',
'platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp',
'platform/graphics/chromium/GraphicsLayerChromium.cpp',
@@ -2275,8 +2273,6 @@
'platform/graphics/chromium/Shader.h',
'platform/graphics/chromium/SimpleFontDataChromiumWin.cpp',
'platform/graphics/chromium/SimpleFontDataLinux.cpp',
- 'platform/graphics/chromium/TilingData.h',
- 'platform/graphics/chromium/TilingData.cpp',
'platform/graphics/chromium/TransparencyWin.cpp',
'platform/graphics/chromium/TransparencyWin.h',
'platform/graphics/chromium/UniscribeHelper.cpp',
@@ -2304,6 +2300,10 @@
'platform/graphics/filters/SourceAlpha.h',
'platform/graphics/filters/SourceGraphic.cpp',
'platform/graphics/filters/SourceGraphic.h',
+ 'platform/graphics/gpu/Texture.cpp',
+ 'platform/graphics/gpu/Texture.h',
+ 'platform/graphics/gpu/TilingData.h',
+ 'platform/graphics/gpu/TilingData.cpp',
'platform/graphics/gtk/ColorGtk.cpp',
'platform/graphics/gtk/FontCacheGtk.cpp',
'platform/graphics/gtk/FontCustomPlatformData.cpp',
diff --git a/WebCore/platform/graphics/chromium/GLES2Canvas.cpp b/WebCore/platform/graphics/chromium/GLES2Canvas.cpp
index 450e9fd..6f594df 100644
--- a/WebCore/platform/graphics/chromium/GLES2Canvas.cpp
+++ b/WebCore/platform/graphics/chromium/GLES2Canvas.cpp
@@ -33,11 +33,11 @@
#include "GLES2Canvas.h"
#include "FloatRect.h"
-#include "GLES2Texture.h"
#include "GraphicsContext3D.h"
#include "IntRect.h"
#include "PlatformString.h"
#include "Shader.h"
+#include "Texture.h"
#define _USE_MATH_DEFINES
#include <math.h>
@@ -164,12 +164,12 @@ void GLES2Canvas::restore()
m_state = &m_stateStack.last();
}
-void GLES2Canvas::drawTexturedRect(GLES2Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp)
+void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace colorSpace, CompositeOperator compositeOp)
{
drawTexturedRect(texture, srcRect, dstRect, m_state->m_ctm, m_state->m_alpha, colorSpace, compositeOp);
}
-void GLES2Canvas::drawTexturedRect(GLES2Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp)
+void GLES2Canvas::drawTexturedRect(Texture* texture, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha, ColorSpace colorSpace, CompositeOperator compositeOp)
{
applyCompositeOperator(compositeOp);
@@ -185,7 +185,7 @@ void GLES2Canvas::drawTexturedRect(GLES2Texture* texture, const FloatRect& srcRe
}
}
-void GLES2Canvas::drawTexturedRectTile(GLES2Texture* texture, int tile, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha)
+void GLES2Canvas::drawTexturedRectTile(Texture* texture, int tile, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform& transform, float alpha)
{
if (dstRect.isEmpty())
return;
@@ -298,21 +298,21 @@ unsigned GLES2Canvas::getQuadVertices()
return m_quadVertices;
}
-GLES2Texture* GLES2Canvas::createTexture(NativeImagePtr ptr, GLES2Texture::Format format, int width, int height)
+Texture* GLES2Canvas::createTexture(NativeImagePtr ptr, Texture::Format format, int width, int height)
{
- PassRefPtr<GLES2Texture> texture = m_textures.get(ptr);
+ PassRefPtr<Texture> texture = m_textures.get(ptr);
if (texture)
return texture.get();
- texture = GLES2Texture::create(m_context, format, width, height);
- GLES2Texture* t = texture.get();
+ texture = Texture::create(m_context, format, width, height);
+ Texture* t = texture.get();
m_textures.set(ptr, texture);
return t;
}
-GLES2Texture* GLES2Canvas::getTexture(NativeImagePtr ptr)
+Texture* GLES2Canvas::getTexture(NativeImagePtr ptr)
{
- PassRefPtr<GLES2Texture> texture = m_textures.get(ptr);
+ PassRefPtr<Texture> texture = m_textures.get(ptr);
return texture ? texture.get() : 0;
}
diff --git a/WebCore/platform/graphics/chromium/GLES2Canvas.h b/WebCore/platform/graphics/chromium/GLES2Canvas.h
index 169e77e..f49ac8b 100644
--- a/WebCore/platform/graphics/chromium/GLES2Canvas.h
+++ b/WebCore/platform/graphics/chromium/GLES2Canvas.h
@@ -34,9 +34,9 @@
#include "AffineTransform.h"
#include "Color.h"
#include "ColorSpace.h"
-#include "GLES2Texture.h"
#include "GraphicsTypes.h"
#include "ImageSource.h"
+#include "Texture.h"
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
@@ -50,7 +50,7 @@ class GraphicsContext3D;
class SolidFillShader;
class TexShader;
-typedef HashMap<NativeImagePtr, RefPtr<GLES2Texture> > TextureHashMap;
+typedef HashMap<NativeImagePtr, RefPtr<Texture> > TextureHashMap;
class GLES2Canvas : public Noncopyable {
public:
@@ -74,14 +74,14 @@ public:
// non-standard functions
// These are not standard GraphicsContext functions, and should be pushed
// down into a PlatformContextGLES2 at some point.
- void drawTexturedRect(GLES2Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator);
- void drawTexturedRect(GLES2Texture*, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator);
+ void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha, ColorSpace, CompositeOperator);
+ void drawTexturedRect(Texture*, const FloatRect& srcRect, const FloatRect& dstRect, ColorSpace, CompositeOperator);
GraphicsContext3D* context() { return m_context; }
- GLES2Texture* createTexture(NativeImagePtr, GLES2Texture::Format, int width, int height);
- GLES2Texture* getTexture(NativeImagePtr);
+ Texture* createTexture(NativeImagePtr, Texture::Format, int width, int height);
+ Texture* getTexture(NativeImagePtr);
private:
- void drawTexturedRectTile(GLES2Texture* texture, int tile, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha);
+ void drawTexturedRectTile(Texture* texture, int tile, const FloatRect& srcRect, const FloatRect& dstRect, const AffineTransform&, float alpha);
void applyCompositeOperator(CompositeOperator);
void checkGLError(const char* header);
unsigned getQuadVertices();
diff --git a/WebCore/platform/graphics/chromium/GLES2Texture.cpp b/WebCore/platform/graphics/chromium/GLES2Texture.cpp
deleted file mode 100644
index 6106522..0000000
--- a/WebCore/platform/graphics/chromium/GLES2Texture.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (c) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR 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 "GLES2Texture.h"
-
-#include "GraphicsContext3D.h"
-#include "IntRect.h"
-#include <wtf/OwnArrayPtr.h>
-
-namespace WebCore {
-
-
-GLES2Texture::GLES2Texture(GraphicsContext3D* context, PassOwnPtr<Vector<unsigned int> > tileTextureIds, Format format, int width, int height, int maxTextureSize)
- : m_context(context)
- , m_format(format)
- , m_tiles(maxTextureSize, width, height, true)
- , m_tileTextureIds(tileTextureIds)
-{
-}
-
-GLES2Texture::~GLES2Texture()
-{
- for (unsigned int i = 0; i < m_tileTextureIds->size(); i++)
- m_context->deleteTexture(m_tileTextureIds->at(i));
-}
-
-static void convertFormat(GraphicsContext3D* context, GLES2Texture::Format format, unsigned int* glFormat, unsigned int* glType, bool* swizzle)
-{
- *swizzle = false;
- switch (format) {
- case GLES2Texture::RGBA8:
- *glFormat = GraphicsContext3D::RGBA;
- *glType = GraphicsContext3D::UNSIGNED_BYTE;
- break;
- case GLES2Texture::BGRA8:
- if (context->supportsBGRA()) {
- *glFormat = GraphicsContext3D::BGRA_EXT;
- *glType = GraphicsContext3D::UNSIGNED_BYTE;
- } else {
- *glFormat = GraphicsContext3D::RGBA;
- *glType = GraphicsContext3D::UNSIGNED_BYTE;
- *swizzle = true;
- }
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
- }
-}
-
-PassRefPtr<GLES2Texture> GLES2Texture::create(GraphicsContext3D* context, Format format, int width, int height)
-{
- int maxTextureSize = 0;
- context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
-
- TilingData tiling(maxTextureSize, width, height, true);
- int numTiles = tiling.numTiles();
-
- OwnPtr<Vector<unsigned int> > textureIds(new Vector<unsigned int>(numTiles));
- textureIds->fill(0, numTiles);
-
- for (int i = 0; i < numTiles; i++) {
- int textureId = context->createTexture();
- if (!textureId) {
- for (int i = 0; i < numTiles; i++)
- context->deleteTexture(textureIds->at(i));
- return 0;
- }
- textureIds->at(i) = textureId;
-
- IntRect tileBoundsWithBorder = tiling.tileBoundsWithBorder(i);
-
- unsigned int glFormat = 0;
- unsigned int glType = 0;
- bool swizzle;
- convertFormat(context, format, &glFormat, &glType, &swizzle);
- context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId);
- context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, glFormat,
- tileBoundsWithBorder.width(),
- tileBoundsWithBorder.height(),
- 0, glFormat, glType, 0);
- }
- return adoptRef(new GLES2Texture(context, textureIds.leakPtr(), format, width, height, maxTextureSize));
-}
-
-template <bool swizzle>
-static uint32_t* copySubRect(uint32_t* src, int srcX, int srcY, uint32_t* dst, int width, int height, int srcStride)
-{
- uint32_t* srcOffset = src + srcX + srcY * srcStride;
-
- if (!swizzle && width == srcStride)
- return srcOffset;
-
- uint32_t* dstPixel = dst;
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width ; x++) {
- uint32_t pixel = srcOffset[x + y * srcStride];
- if (swizzle)
- *dstPixel = pixel & 0xFF00FF00 | ((pixel & 0x00FF0000) >> 16) | ((pixel & 0x000000FF) << 16);
- else
- *dstPixel = pixel;
- dstPixel++;
- }
- }
- return dst;
-}
-
-void GLES2Texture::load(void* pixels)
-{
- uint32_t* pixels32 = static_cast<uint32_t*>(pixels);
- unsigned int glFormat = 0;
- unsigned int glType = 0;
- bool swizzle;
- convertFormat(m_context, m_format, &glFormat, &glType, &swizzle);
- if (swizzle) {
- ASSERT(glFormat == GraphicsContext3D::RGBA && glType == GraphicsContext3D::UNSIGNED_BYTE);
- // FIXME: This could use PBO's to save doing an extra copy here.
- }
- OwnArrayPtr<uint32_t> tempBuff(new uint32_t[m_tiles.maxTextureSize() * m_tiles.maxTextureSize()]);
-
- for (int i = 0; i < m_tiles.numTiles(); i++) {
- IntRect tileBoundsWithBorder = m_tiles.tileBoundsWithBorder(i);
-
- uint32_t* uploadBuff = 0;
- if (swizzle) {
- uploadBuff = copySubRect<true>(
- pixels32, tileBoundsWithBorder.x(), tileBoundsWithBorder.y(),
- tempBuff.get(), tileBoundsWithBorder.width(), tileBoundsWithBorder.height(), m_tiles.totalSizeX());
- } else {
- uploadBuff = copySubRect<false>(
- pixels32, tileBoundsWithBorder.x(), tileBoundsWithBorder.y(),
- tempBuff.get(), tileBoundsWithBorder.width(), tileBoundsWithBorder.height(), m_tiles.totalSizeX());
- }
-
- m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_tileTextureIds->at(i));
- m_context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0,
- tileBoundsWithBorder.width(),
- tileBoundsWithBorder.height(), glFormat, glType, uploadBuff);
- }
-}
-
-void GLES2Texture::bindTile(int tile)
-{
- m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_tileTextureIds->at(tile));
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
- m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
-}
-
-}
diff --git a/WebCore/platform/graphics/chromium/GLES2Texture.h b/WebCore/platform/graphics/chromium/GLES2Texture.h
deleted file mode 100644
index 5fd37ca..0000000
--- a/WebCore/platform/graphics/chromium/GLES2Texture.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2010, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
- * OWNER OR 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 GLES2Texture_h
-#define GLES2Texture_h
-
-#include "RefCounted.h"
-#include "RefPtr.h"
-#include "TilingData.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-class GraphicsContext3D;
-
-class GLES2Texture : public RefCounted<GLES2Texture> {
-public:
- ~GLES2Texture();
- enum Format { RGBA8, BGRA8 };
- static PassRefPtr<GLES2Texture> create(GraphicsContext3D*, Format, int width, int height);
- void bindTile(int tile);
- void load(void* pixels);
- Format format() const { return m_format; }
- const TilingData& tiles() const { return m_tiles; }
-private:
- GLES2Texture(GraphicsContext3D*, PassOwnPtr<Vector<unsigned int> > tileTextureIds, Format format, int width, int height, int maxTextureSize);
- GraphicsContext3D* m_context;
- Format m_format;
- TilingData m_tiles;
- OwnPtr<Vector<unsigned int> > m_tileTextureIds;
-};
-
-}
-
-#endif // GLES2Texture_h
diff --git a/WebCore/platform/graphics/gpu/Texture.cpp b/WebCore/platform/graphics/gpu/Texture.cpp
new file mode 100644
index 0000000..557603c
--- /dev/null
+++ b/WebCore/platform/graphics/gpu/Texture.cpp
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2010, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 "Texture.h"
+
+#include "GraphicsContext3D.h"
+#include "IntRect.h"
+#include <wtf/OwnArrayPtr.h>
+
+namespace WebCore {
+
+
+Texture::Texture(GraphicsContext3D* context, PassOwnPtr<Vector<unsigned int> > tileTextureIds, Format format, int width, int height, int maxTextureSize)
+ : m_context(context)
+ , m_format(format)
+ , m_tiles(maxTextureSize, width, height, true)
+ , m_tileTextureIds(tileTextureIds)
+{
+}
+
+Texture::~Texture()
+{
+ for (unsigned int i = 0; i < m_tileTextureIds->size(); i++)
+ m_context->deleteTexture(m_tileTextureIds->at(i));
+}
+
+static void convertFormat(GraphicsContext3D* context, Texture::Format format, unsigned int* glFormat, unsigned int* glType, bool* swizzle)
+{
+ *swizzle = false;
+ switch (format) {
+ case Texture::RGBA8:
+ *glFormat = GraphicsContext3D::RGBA;
+ *glType = GraphicsContext3D::UNSIGNED_BYTE;
+ break;
+ case Texture::BGRA8:
+ if (context->supportsBGRA()) {
+ *glFormat = GraphicsContext3D::BGRA_EXT;
+ *glType = GraphicsContext3D::UNSIGNED_BYTE;
+ } else {
+ *glFormat = GraphicsContext3D::RGBA;
+ *glType = GraphicsContext3D::UNSIGNED_BYTE;
+ *swizzle = true;
+ }
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+}
+
+PassRefPtr<Texture> Texture::create(GraphicsContext3D* context, Format format, int width, int height)
+{
+ int maxTextureSize = 0;
+ context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize);
+
+ TilingData tiling(maxTextureSize, width, height, true);
+ int numTiles = tiling.numTiles();
+
+ OwnPtr<Vector<unsigned int> > textureIds(new Vector<unsigned int>(numTiles));
+ textureIds->fill(0, numTiles);
+
+ for (int i = 0; i < numTiles; i++) {
+ int textureId = context->createTexture();
+ if (!textureId) {
+ for (int i = 0; i < numTiles; i++)
+ context->deleteTexture(textureIds->at(i));
+ return 0;
+ }
+ textureIds->at(i) = textureId;
+
+ IntRect tileBoundsWithBorder = tiling.tileBoundsWithBorder(i);
+
+ unsigned int glFormat = 0;
+ unsigned int glType = 0;
+ bool swizzle;
+ convertFormat(context, format, &glFormat, &glType, &swizzle);
+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, textureId);
+ context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, glFormat,
+ tileBoundsWithBorder.width(),
+ tileBoundsWithBorder.height(),
+ 0, glFormat, glType, 0);
+ }
+ return adoptRef(new Texture(context, textureIds.leakPtr(), format, width, height, maxTextureSize));
+}
+
+template <bool swizzle>
+static uint32_t* copySubRect(uint32_t* src, int srcX, int srcY, uint32_t* dst, int width, int height, int srcStride)
+{
+ uint32_t* srcOffset = src + srcX + srcY * srcStride;
+
+ if (!swizzle && width == srcStride)
+ return srcOffset;
+
+ uint32_t* dstPixel = dst;
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width ; x++) {
+ uint32_t pixel = srcOffset[x + y * srcStride];
+ if (swizzle)
+ *dstPixel = pixel & 0xFF00FF00 | ((pixel & 0x00FF0000) >> 16) | ((pixel & 0x000000FF) << 16);
+ else
+ *dstPixel = pixel;
+ dstPixel++;
+ }
+ }
+ return dst;
+}
+
+void Texture::load(void* pixels)
+{
+ uint32_t* pixels32 = static_cast<uint32_t*>(pixels);
+ unsigned int glFormat = 0;
+ unsigned int glType = 0;
+ bool swizzle;
+ convertFormat(m_context, m_format, &glFormat, &glType, &swizzle);
+ if (swizzle) {
+ ASSERT(glFormat == GraphicsContext3D::RGBA && glType == GraphicsContext3D::UNSIGNED_BYTE);
+ // FIXME: This could use PBO's to save doing an extra copy here.
+ }
+ OwnArrayPtr<uint32_t> tempBuff(new uint32_t[m_tiles.maxTextureSize() * m_tiles.maxTextureSize()]);
+
+ for (int i = 0; i < m_tiles.numTiles(); i++) {
+ IntRect tileBoundsWithBorder = m_tiles.tileBoundsWithBorder(i);
+
+ uint32_t* uploadBuff = 0;
+ if (swizzle) {
+ uploadBuff = copySubRect<true>(
+ pixels32, tileBoundsWithBorder.x(), tileBoundsWithBorder.y(),
+ tempBuff.get(), tileBoundsWithBorder.width(), tileBoundsWithBorder.height(), m_tiles.totalSizeX());
+ } else {
+ uploadBuff = copySubRect<false>(
+ pixels32, tileBoundsWithBorder.x(), tileBoundsWithBorder.y(),
+ tempBuff.get(), tileBoundsWithBorder.width(), tileBoundsWithBorder.height(), m_tiles.totalSizeX());
+ }
+
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_tileTextureIds->at(i));
+ m_context->texSubImage2D(GraphicsContext3D::TEXTURE_2D, 0, 0, 0,
+ tileBoundsWithBorder.width(),
+ tileBoundsWithBorder.height(), glFormat, glType, uploadBuff);
+ }
+}
+
+void Texture::bindTile(int tile)
+{
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_tileTextureIds->at(tile));
+ m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
+ m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
+ m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+ m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
+}
+
+}
diff --git a/WebCore/platform/graphics/gpu/Texture.h b/WebCore/platform/graphics/gpu/Texture.h
new file mode 100644
index 0000000..7e4a72b
--- /dev/null
+++ b/WebCore/platform/graphics/gpu/Texture.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2010, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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 Texture_h
+#define Texture_h
+
+#include "RefCounted.h"
+#include "RefPtr.h"
+#include "TilingData.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class GraphicsContext3D;
+
+class Texture : public RefCounted<Texture> {
+public:
+ ~Texture();
+ enum Format { RGBA8, BGRA8 };
+ static PassRefPtr<Texture> create(GraphicsContext3D*, Format, int width, int height);
+ void bindTile(int tile);
+ void load(void* pixels);
+ Format format() const { return m_format; }
+ const TilingData& tiles() const { return m_tiles; }
+private:
+ Texture(GraphicsContext3D*, PassOwnPtr<Vector<unsigned int> > tileTextureIds, Format format, int width, int height, int maxTextureSize);
+ GraphicsContext3D* m_context;
+ Format m_format;
+ TilingData m_tiles;
+ OwnPtr<Vector<unsigned int> > m_tileTextureIds;
+};
+
+}
+
+#endif // Texture_h
diff --git a/WebCore/platform/graphics/chromium/TilingData.cpp b/WebCore/platform/graphics/gpu/TilingData.cpp
old mode 100755
new mode 100644
similarity index 100%
rename from WebCore/platform/graphics/chromium/TilingData.cpp
rename to WebCore/platform/graphics/gpu/TilingData.cpp
diff --git a/WebCore/platform/graphics/chromium/TilingData.h b/WebCore/platform/graphics/gpu/TilingData.h
old mode 100755
new mode 100644
similarity index 100%
rename from WebCore/platform/graphics/chromium/TilingData.h
rename to WebCore/platform/graphics/gpu/TilingData.h
diff --git a/WebCore/platform/graphics/skia/ImageSkia.cpp b/WebCore/platform/graphics/skia/ImageSkia.cpp
index 5af1090..aed289f 100644
--- a/WebCore/platform/graphics/skia/ImageSkia.cpp
+++ b/WebCore/platform/graphics/skia/ImageSkia.cpp
@@ -411,11 +411,11 @@ static void drawBitmapGLES2(GraphicsContext* ctxt, NativeImageSkia* bitmap, cons
{
ctxt->platformContext()->prepareForHardwareDraw();
GLES2Canvas* gpuCanvas = ctxt->platformContext()->gpuCanvas();
- GLES2Texture* texture = gpuCanvas->getTexture(bitmap);
+ Texture* texture = gpuCanvas->getTexture(bitmap);
if (!texture) {
ASSERT(bitmap->config() == SkBitmap::kARGB_8888_Config);
ASSERT(bitmap->rowBytes() == bitmap->width() * 4);
- texture = gpuCanvas->createTexture(bitmap, GLES2Texture::BGRA8, bitmap->width(), bitmap->height());
+ texture = gpuCanvas->createTexture(bitmap, Texture::BGRA8, bitmap->width(), bitmap->height());
SkAutoLockPixels lock(*bitmap);
ASSERT(bitmap->getPixels());
texture->load(bitmap->getPixels());
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
index af0c4c4..3b1d015 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
@@ -35,13 +35,12 @@
#include "AffineTransform.h"
#include "CanvasLayerChromium.h"
#include "GLES2Canvas.h"
-#include "GLES2Texture.h"
#include "GraphicsContext.h"
#include "GraphicsContext3D.h"
#include "ImageBuffer.h"
#include "NativeImageSkia.h"
-#include "PlatformContextSkia.h"
#include "SkiaUtils.h"
+#include "Texture.h"
#include "TilingData.h"
#include "skia/ext/image_operations.h"
@@ -49,8 +48,8 @@
#include "SkBitmap.h"
#include "SkColorPriv.h"
-#include "SkShader.h"
#include "SkDashPathEffect.h"
+#include "SkShader.h"
#include <wtf/MathExtras.h>
#include <wtf/OwnArrayPtr.h>
@@ -787,7 +786,7 @@ void PlatformContextSkia::uploadSoftwareToHardware(CompositeOperator op) const
SkAutoLockPixels lock(bitmap);
GraphicsContext3D* context = m_gpuCanvas->context();
if (!m_uploadTexture || m_uploadTexture->tiles().totalSizeX() < bitmap.width() || m_uploadTexture->tiles().totalSizeY() < bitmap.height())
- m_uploadTexture = GLES2Texture::create(context, GLES2Texture::BGRA8, bitmap.width(), bitmap.height());
+ m_uploadTexture = Texture::create(context, Texture::BGRA8, bitmap.width(), bitmap.height());
m_uploadTexture->load(bitmap.getPixels());
IntRect rect(0, 0, bitmap.width(), bitmap.height());
AffineTransform identity;
diff --git a/WebCore/platform/graphics/skia/PlatformContextSkia.h b/WebCore/platform/graphics/skia/PlatformContextSkia.h
index fc0fb0b..82edc16 100644
--- a/WebCore/platform/graphics/skia/PlatformContextSkia.h
+++ b/WebCore/platform/graphics/skia/PlatformContextSkia.h
@@ -35,11 +35,11 @@
#include "Noncopyable.h"
#include "SkDashPathEffect.h"
-#include "SkDrawLooper.h"
#include "SkDeque.h"
-#include "skia/ext/platform_canvas.h"
+#include "SkDrawLooper.h"
#include "SkPaint.h"
#include "SkPath.h"
+#include "skia/ext/platform_canvas.h"
#include <wtf/Vector.h>
@@ -47,7 +47,7 @@ namespace WebCore {
enum CompositeOperator;
class GLES2Canvas;
-class GLES2Texture;
+class Texture;
class GraphicsContext3D;
// This class holds the platform-specific state for GraphicsContext. We put
@@ -228,7 +228,7 @@ private:
bool m_useGPU;
OwnPtr<GLES2Canvas> m_gpuCanvas;
mutable enum { None, Software, Mixed, Hardware } m_backingStoreState;
- mutable RefPtr<GLES2Texture> m_uploadTexture;
+ mutable RefPtr<Texture> m_uploadTexture;
};
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list