summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/android')
-rw-r--r--Source/WebCore/platform/graphics/android/FontAndroid.cpp7
-rw-r--r--Source/WebCore/platform/graphics/android/FontCustomPlatformData.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/FontCustomPlatformData.h3
-rw-r--r--Source/WebCore/platform/graphics/android/FontDataAndroid.cpp26
-rw-r--r--Source/WebCore/platform/graphics/android/GLWebViewState.cpp2
-rw-r--r--Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp60
-rw-r--r--Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp6
-rw-r--r--Source/WebCore/platform/graphics/android/LayerAndroid.cpp4
-rw-r--r--Source/WebCore/platform/graphics/android/PathAndroid.cpp31
-rw-r--r--Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h2
-rw-r--r--Source/WebCore/platform/graphics/android/ShaderProgram.cpp40
-rw-r--r--Source/WebCore/platform/graphics/android/TiledPage.cpp6
12 files changed, 59 insertions, 130 deletions
diff --git a/Source/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
index 7fcad73..af2edc7 100644
--- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp
@@ -161,6 +161,11 @@ bool Font::canReturnFallbackFontsForComplexText()
return false;
}
+bool Font::canExpandAroundIdeographsInComplexText()
+{
+ return false;
+}
+
void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
const GlyphBuffer& glyphBuffer, int from, int numGlyphs,
const FloatPoint& point) const
@@ -918,7 +923,7 @@ void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
bool haveMultipleLayers = isCanvasMultiLayered(canvas);
TextRunWalker walker(run, point.x(), this);
walker.setWordAndLetterSpacing(wordSpacing(), letterSpacing());
- walker.setPadding(run.padding());
+ walker.setPadding(run.expansion());
while (walker.nextScriptRun()) {
if (fill) {
diff --git a/Source/WebCore/platform/graphics/android/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/android/FontCustomPlatformData.cpp
index 4795d9e..7190f32 100644
--- a/Source/WebCore/platform/graphics/android/FontCustomPlatformData.cpp
+++ b/Source/WebCore/platform/graphics/android/FontCustomPlatformData.cpp
@@ -46,7 +46,7 @@ FontCustomPlatformData::~FontCustomPlatformData()
}
FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic,
- FontOrientation, FontRenderingMode)
+ FontOrientation, FontWidthVariant, FontRenderingMode)
{
// turn bold/italic into fakeBold/fakeItalic
if (m_typeface != NULL) {
diff --git a/Source/WebCore/platform/graphics/android/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/android/FontCustomPlatformData.h
index b03afa9..f74abc5 100644
--- a/Source/WebCore/platform/graphics/android/FontCustomPlatformData.h
+++ b/Source/WebCore/platform/graphics/android/FontCustomPlatformData.h
@@ -28,6 +28,7 @@
#include "FontOrientation.h"
#include "FontRenderingMode.h"
+#include "FontWidthVariant.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
@@ -46,7 +47,7 @@ public:
SkTypeface* typeface() const { return m_typeface; }
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontRenderingMode);
+ FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode);
static bool supportsFormat(const String&);
private:
diff --git a/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp b/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp
index 545dcf7..1f19b6d 100644
--- a/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/FontDataAndroid.cpp
@@ -43,22 +43,20 @@ namespace WebCore {
void SimpleFontData::platformInit()
{
SkPaint paint;
- SkPaint::FontMetrics metrics;
+ SkPaint::FontMetrics skiaFontMetrics;
m_platformData.setupPaint(&paint);
- (void)paint.getFontMetrics(&metrics);
-
- // use ceil instead of round to favor descent, given a lot of accidental
- // clipping of descenders (e.g. 14pt 'g') in textedit fields
- int d = SkScalarCeil(metrics.fDescent);
- int s = SkScalarRound(metrics.fDescent - metrics.fAscent);
- int a = s - d;
-
- m_ascent = a;
- m_descent = d;
- m_xHeight = SkScalarToFloat(-metrics.fAscent) * 0.56f; // hack I stole from the window's port
- m_lineSpacing = a + d;
- m_lineGap = SkScalarRound(metrics.fLeading);
+ paint.getFontMetrics(&skiaFontMetrics);
+
+ float d = SkScalarToFloat(skiaFontMetrics.fDescent);
+ float s = SkScalarToFloat(skiaFontMetrics.fDescent - skiaFontMetrics.fAscent);
+ float a = s - d;
+
+ m_fontMetrics.setAscent(a);
+ m_fontMetrics.setDescent(d);
+ m_fontMetrics.setXHeight(SkScalarToFloat(-skiaFontMetrics.fAscent) * 0.56f); // hack I stole from the window's port
+ m_fontMetrics.setLineSpacing(a + d);
+ m_fontMetrics.setLineGap(SkScalarToFloat(skiaFontMetrics.fLeading));
}
void SimpleFontData::platformCharWidthInit()
diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
index f46d335..966670d 100644
--- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
+++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp
@@ -229,7 +229,7 @@ void GLWebViewState::inval(const IntRect& rect)
rect.x(), rect.y(), rect.right(), rect.bottom());
}
} else {
- m_invalidateRegion.op(rect.x(), rect.y(), rect.right(), rect.bottom(), SkRegion::kUnion_Op);
+ m_invalidateRegion.op(rect.x(), rect.y(), rect.maxX(), rect.maxY(), SkRegion::kUnion_Op);
}
}
diff --git a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
index 888be5b..012c1a8 100644
--- a/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
@@ -115,7 +115,6 @@ struct ShadowRec {
class GraphicsContextPlatformPrivate {
public:
struct State {
- SkPath* path;
SkPathEffect* pathEffect;
float miterLimit;
float alpha;
@@ -133,8 +132,7 @@ public:
WTF::Vector<SkPath> antiAliasClipPaths;
State()
- : path(0) // Lazily allocated
- , pathEffect(0)
+ : pathEffect(0)
, miterLimit(4)
, alpha(1)
, strokeThickness(0) // Same as default in GraphicsContextPrivate.h
@@ -162,13 +160,11 @@ public:
, strokeColor(other.strokeColor)
, useAA(other.useAA)
{
- path = deepCopyPtr<SkPath>(other.path);
SkSafeRef(pathEffect);
}
~State()
{
- delete path;
SkSafeUnref(pathEffect);
}
@@ -273,26 +269,6 @@ public:
m_state->strokeThickness = f;
}
- void beginPath()
- {
- if (m_state->path)
- m_state->path->reset();
- }
-
- void addPath(const SkPath& other)
- {
- if (!m_state->path)
- m_state->path = new SkPath(other);
- else
- m_state->path->addPath(other);
- }
-
- // May return null
- SkPath* getPath() const
- {
- return m_state->path;
- }
-
void setupPaintCommon(SkPaint* paint) const
{
paint->setAntiAlias(m_state->useAA);
@@ -538,11 +514,6 @@ bool GraphicsContext::willStroke() const
return m_data->getState()->strokeColor;
}
-const SkPath* GraphicsContext::getCurrPath() const
-{
- return m_data->getState()->path;
-}
-
// Draws a filled rectangle with a stroked border.
void GraphicsContext::drawRect(const IntRect& rect)
{
@@ -909,12 +880,7 @@ void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule)
if (paintingDisabled())
return;
- // FIXME: Be smarter about this.
- beginPath();
- addPath(pathToClip);
-
- const SkPath* oldPath = m_data->getPath();
- SkPath path(*oldPath);
+ SkPath path = *pathToClip.platformPath();
path.setFillType(clipRule == RULE_EVENODD ? SkPath::kEvenOdd_FillType : SkPath::kWinding_FillType);
GC2CANVAS(this)->clipPath(path);
}
@@ -1231,23 +1197,9 @@ AffineTransform GraphicsContext::getCTM() const
///////////////////////////////////////////////////////////////////////////////
-void GraphicsContext::beginPath()
-{
- m_data->beginPath();
-}
-
-void GraphicsContext::addPath(const Path& p)
-{
- m_data->addPath(*p.platformPath());
-}
-
void GraphicsContext::fillPath(const Path& pathToFill)
{
- // FIXME: Be smarter about this.
- beginPath();
- addPath(pathToFill);
-
- SkPath* path = m_data->getPath();
+ SkPath* path = pathToFill.platformPath();
if (paintingDisabled() || !path)
return;
@@ -1272,11 +1224,7 @@ void GraphicsContext::fillPath(const Path& pathToFill)
void GraphicsContext::strokePath(const Path& pathToStroke)
{
- // FIXME: Be smarter about this.
- beginPath();
- addPath(pathToStroke);
-
- const SkPath* path = m_data->getPath();
+ const SkPath* path = pathToStroke.platformPath();
if (paintingDisabled() || !path)
return;
diff --git a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
index 0a36051..5807f87 100644
--- a/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
@@ -120,7 +120,7 @@ PassRefPtr<ByteArray> ImageBuffer::getUnmultipliedImageData(const IntRect& rect)
RefPtr<ByteArray> result = ByteArray::create(rect.width() * rect.height() * 4);
unsigned char* data = result->data();
- if (rect.x() < 0 || rect.y() < 0 || rect.right() > m_size.width() || rect.bottom() > m_size.height())
+ if (rect.x() < 0 || rect.y() < 0 || rect.maxX() > m_size.width() || rect.maxY() > m_size.height())
memset(data, 0, result->length());
int originx = rect.x();
@@ -189,7 +189,7 @@ void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sou
ASSERT(originx >= 0);
ASSERT(originx <= sourceRect.right());
- int endx = destPoint.x() + sourceRect.right();
+ int endx = destPoint.x() + sourceRect.maxX();
ASSERT(endx <= m_size.width());
int numColumns = endx - destx;
@@ -201,7 +201,7 @@ void ImageBuffer::putUnmultipliedImageData(ByteArray* source, const IntSize& sou
ASSERT(originy >= 0);
ASSERT(originy <= sourceRect.bottom());
- int endy = destPoint.y() + sourceRect.bottom();
+ int endy = destPoint.y() + sourceRect.maxY();
ASSERT(endy <= m_size.height());
int numRows = endy - desty;
diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
index c0fbf61..34c02e9 100644
--- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp
@@ -600,7 +600,7 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix,
localMatrix.translate3d(originX + position.x(),
originY + position.y(),
anchorPointZ());
- localMatrix.multLeft(m_transform);
+ localMatrix.multiply(m_transform);
localMatrix.translate3d(-originX,
-originY,
-anchorPointZ());
@@ -648,7 +648,7 @@ void LayerAndroid::updateGLPositions(const TransformationMatrix& parentMatrix,
if (!m_childrenTransform.isIdentity()) {
localMatrix.translate(getSize().width() * 0.5f, getSize().height() * 0.5f);
- localMatrix.multLeft(m_childrenTransform);
+ localMatrix.multiply(m_childrenTransform);
localMatrix.translate(-getSize().width() * 0.5f, -getSize().height() * 0.5f);
}
for (int i = 0; i < count; i++)
diff --git a/Source/WebCore/platform/graphics/android/PathAndroid.cpp b/Source/WebCore/platform/graphics/android/PathAndroid.cpp
index e0d7171..ad345bb 100644
--- a/Source/WebCore/platform/graphics/android/PathAndroid.cpp
+++ b/Source/WebCore/platform/graphics/android/PathAndroid.cpp
@@ -285,35 +285,20 @@ void Path::transform(const AffineTransform& xform)
///////////////////////////////////////////////////////////////////////////////
-// Computes the bounding box for the stroke and style currently selected into
-// the given bounding box. This also takes into account the stroke width.
-static FloatRect boundingBoxForCurrentStroke(GraphicsContext* context)
-{
- const SkPath* path = context->getCurrPath();
- if (NULL == path) {
- return FloatRect();
- }
-
- SkPaint paint;
- context->setupStrokePaint(&paint);
- SkPath fillPath;
- paint.getFillPath(*path, &fillPath);
- const SkRect& r = fillPath.getBounds();
- return FloatRect(SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop),
- SkScalarToFloat(r.width()), SkScalarToFloat(r.height()));
-}
-
FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier)
{
GraphicsContext* scratch = scratchContext();
scratch->save();
- scratch->beginPath();
- scratch->addPath(*this);
-
+
if (applier)
applier->strokeStyle(scratch);
-
- FloatRect r = boundingBoxForCurrentStroke(scratch);
+
+ SkPaint paint;
+ scratch->setupStrokePaint(&paint);
+ SkPath boundingPath;
+ paint.getFillPath(*platformPath(), &boundingPath);
+
+ FloatRect r = boundingPath.getBounds();
scratch->restore();
return r;
}
diff --git a/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h
index 0ce86d2..98fcc49 100644
--- a/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h
+++ b/Source/WebCore/platform/graphics/android/PlatformGraphicsContext.h
@@ -118,7 +118,7 @@ public:
state == WebCore::RenderSkinAndroid::kFocused)
return;
m_state = state;
- SkCanvas* canvas = m_picture->beginRecording(m_rect.right(), m_rect.bottom());
+ SkCanvas* canvas = m_picture->beginRecording(m_rect.maxX(), m_rect.maxY());
buttonSkin->draw(canvas, m_rect, state);
m_picture->endRecording();
}
diff --git a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
index 0117bc0..f2b2dc8 100644
--- a/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
+++ b/Source/WebCore/platform/graphics/android/ShaderProgram.cpp
@@ -224,9 +224,7 @@ void ShaderProgram::setProjectionMatrix(SkRect& geometry)
TransformationMatrix scale;
scale.scale3d(geometry.width(), geometry.height(), 1.0);
- TransformationMatrix total = m_projectionMatrix;
- total.multLeft(translate);
- total.multLeft(scale);
+ TransformationMatrix total = m_projectionMatrix * translate * scale;
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, total);
@@ -264,14 +262,10 @@ void ShaderProgram::setViewRect(const IntRect& viewRect)
TransformationMatrix scale;
scale.scale3d(m_viewRect.width() * 0.5f, m_viewRect.height() * 0.5f, 1);
- m_documentToScreenMatrix = m_projectionMatrix;
- m_documentToScreenMatrix.multiply(translate);
- m_documentToScreenMatrix.multiply(scale);
+ m_documentToScreenMatrix = scale * translate * m_projectionMatrix;
- m_documentToInvScreenMatrix = m_projectionMatrix;
translate.scale3d(1, -1, 1);
- m_documentToInvScreenMatrix.multiply(translate);
- m_documentToInvScreenMatrix.multiply(scale);
+ m_documentToInvScreenMatrix = scale * translate * m_projectionMatrix;
}
// This function transform a clip rect extracted from the current layer
@@ -279,8 +273,7 @@ void ShaderProgram::setViewRect(const IntRect& viewRect)
FloatRect ShaderProgram::rectInScreenCoord(const TransformationMatrix& drawMatrix, const IntSize& size)
{
FloatRect srect(0, 0, size.width(), size.height());
- TransformationMatrix renderMatrix = drawMatrix;
- renderMatrix.multiply(m_documentToScreenMatrix);
+ TransformationMatrix renderMatrix = m_documentToScreenMatrix * drawMatrix;
return renderMatrix.mapRect(srect);
}
@@ -288,8 +281,7 @@ FloatRect ShaderProgram::rectInScreenCoord(const TransformationMatrix& drawMatri
FloatRect ShaderProgram::rectInInvScreenCoord(const TransformationMatrix& drawMatrix, const IntSize& size)
{
FloatRect srect(0, 0, size.width(), size.height());
- TransformationMatrix renderMatrix = drawMatrix;
- renderMatrix.multiply(m_documentToInvScreenMatrix);
+ TransformationMatrix renderMatrix = m_documentToInvScreenMatrix * drawMatrix;
return renderMatrix.mapRect(srect);
}
@@ -372,9 +364,9 @@ IntRect ShaderProgram::clippedRectWithViewport(const IntRect& rect, int margin)
float ShaderProgram::zValue(const TransformationMatrix& drawMatrix, float w, float h)
{
- TransformationMatrix renderMatrix = drawMatrix;
- renderMatrix.scale3d(w, h, 1);
- renderMatrix.multiply(m_projectionMatrix);
+ TransformationMatrix modifiedDrawMatrix = drawMatrix;
+ modifiedDrawMatrix.scale3d(w, h, 1);
+ TransformationMatrix renderMatrix = m_projectionMatrix * modifiedDrawMatrix;
FloatPoint3D point(0.5, 0.5, 0.0);
FloatPoint3D result = renderMatrix.mapPoint(point);
return result.z();
@@ -385,11 +377,11 @@ void ShaderProgram::drawLayerQuad(const TransformationMatrix& drawMatrix,
bool forceBlending)
{
- TransformationMatrix renderMatrix = drawMatrix;
+ TransformationMatrix modifiedDrawMatrix = drawMatrix;
// move the drawing depending on where the texture is on the layer
- renderMatrix.translate(geometry.fLeft, geometry.fTop);
- renderMatrix.scale3d(geometry.width(), geometry.height(), 1);
- renderMatrix.multiply(m_projectionMatrix);
+ modifiedDrawMatrix.translate(geometry.fLeft, geometry.fTop);
+ modifiedDrawMatrix.scale3d(geometry.width(), geometry.height(), 1);
+ TransformationMatrix renderMatrix = m_projectionMatrix * modifiedDrawMatrix;
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
@@ -414,10 +406,10 @@ void ShaderProgram::drawVideoLayerQuad(const TransformationMatrix& drawMatrix,
// switch to our custom yuv video rendering program
glUseProgram(m_videoProgram);
- TransformationMatrix renderMatrix = drawMatrix;
- renderMatrix.translate(geometry.fLeft, geometry.fTop);
- renderMatrix.scale3d(geometry.width(), geometry.height(), 1);
- renderMatrix.multiply(m_projectionMatrix);
+ TransformationMatrix modifiedDrawMatrix = drawMatrix;
+ modifiedDrawMatrix.translate(geometry.fLeft, geometry.fTop);
+ modifiedDrawMatrix.scale3d(geometry.width(), geometry.height(), 1);
+ TransformationMatrix renderMatrix = m_projectionMatrix * modifiedDrawMatrix;
GLfloat projectionMatrix[16];
GLUtils::toGLMatrix(projectionMatrix, renderMatrix);
diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp
index 5212871..0e1e947 100644
--- a/Source/WebCore/platform/graphics/android/TiledPage.cpp
+++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp
@@ -122,14 +122,14 @@ void TiledPage::invalidateRect(const IntRect& inval, const unsigned int pictureC
const int firstDirtyTileX = static_cast<int>(floorf(inval.x() * invTileContentWidth));
const int firstDirtyTileY = static_cast<int>(floorf(inval.y() * invTileContentHeight));
- const int lastDirtyTileX = static_cast<int>(ceilf(inval.right() * invTileContentWidth));
- const int lastDirtyTileY = static_cast<int>(ceilf(inval.bottom() * invTileContentHeight));
+ const int lastDirtyTileX = static_cast<int>(ceilf(inval.maxX() * invTileContentWidth));
+ const int lastDirtyTileY = static_cast<int>(ceilf(inval.maxY() * invTileContentHeight));
XLOG("Marking X %d-%d and Y %d-%d dirty", firstDirtyTileX, lastDirtyTileX, firstDirtyTileY, lastDirtyTileY);
// We defer marking the tile as dirty until the next time we need to prepare
// to draw.
m_invalRegion.op(firstDirtyTileX, firstDirtyTileY, lastDirtyTileX, lastDirtyTileY, SkRegion::kUnion_Op);
- m_invalTilesRegion.op(inval.x(), inval.y(), inval.right(), inval.bottom(), SkRegion::kUnion_Op);
+ m_invalTilesRegion.op(inval.x(), inval.y(), inval.maxX(), inval.maxY(), SkRegion::kUnion_Op);
m_latestPictureInval = pictureCount;
}