diff options
Diffstat (limited to 'Source/WebCore')
16 files changed, 44 insertions, 31 deletions
diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h index 56aceff..14537c8 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContext.h @@ -148,6 +148,7 @@ public: const IntRect& thumb = IntRect()) = 0; virtual SkCanvas* recordingCanvas() = 0; + virtual void setTextOffset(FloatSize offset) = 0; void setRawState(State* state) { m_state = state; } diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp index 867ff56..a410ba9 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.cpp @@ -498,7 +498,7 @@ PlatformGraphicsContextRecording::PlatformGraphicsContextRecording(Recording* re , mPicture(0) , mRecording(recording) , mOperationState(0) - , m_hasText(false) + , m_maxZoomScale(1) , m_isEmpty(true) , m_canvasProxy(this) { @@ -524,7 +524,7 @@ bool PlatformGraphicsContextRecording::isPaintingDisabled() SkCanvas* PlatformGraphicsContextRecording::recordingCanvas() { - m_hasText = true; + m_maxZoomScale = 1e6f; return &m_canvasProxy; } @@ -779,6 +779,9 @@ void PlatformGraphicsContextRecording::drawBitmapRect(const SkBitmap& bitmap, const SkIRect* src, const SkRect& dst, CompositeOperator op) { + float widthScale = dst.width() == 0 ? 1 : bitmap.width() / dst.width(); + float heightScale = dst.height() == 0 ? 1 : bitmap.height() / dst.height(); + m_maxZoomScale = std::max(m_maxZoomScale, std::max(widthScale, heightScale)); appendDrawingOperation(NEW_OP(DrawBitmapRect)(bitmap, *src, dst, op), dst); } @@ -914,6 +917,8 @@ void PlatformGraphicsContextRecording::drawPosText(const void* inText, size_t by return; } FloatRect bounds = approximateTextBounds(byteLength / sizeof(uint16_t), inPos, inPaint); + bounds.move(m_textOffset); // compensate font rendering-side translates + const SkPaint* paint = mRecording->recording()->getSkPaint(inPaint); size_t posSize = sizeof(SkPoint) * paint->countText(inText, byteLength); void* text = heap()->alloc(byteLength); diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h index 061ee0e..a8e69f5 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextRecording.h @@ -64,6 +64,7 @@ public: virtual bool isPaintingDisabled(); virtual SkCanvas* recordingCanvas(); + virtual void setTextOffset(FloatSize offset) { m_textOffset = offset; } virtual ContextType type() { return RecordingContext; } @@ -143,7 +144,7 @@ public: bool translucent = false, bool drawBackground = true, const IntRect& thumb = IntRect()); - bool hasText() { return m_hasText; } + float maxZoomScale() { return m_maxZoomScale; } bool isEmpty() { return m_isEmpty; } private: @@ -206,9 +207,10 @@ private: Vector<SkMatrix> mMatrixStack; State* mOperationState; - bool m_hasText; + float m_maxZoomScale; bool m_isEmpty; RecordingContextCanvasProxy m_canvasProxy; + FloatSize m_textOffset; }; } diff --git a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h index 6bf53d7..2c1d8cb 100644 --- a/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h +++ b/Source/WebCore/platform/graphics/android/context/PlatformGraphicsContextSkia.h @@ -39,6 +39,7 @@ public: virtual ContextType type() { return PaintingContext; } virtual SkCanvas* recordingCanvas() { return mCanvas; } + virtual void setTextOffset(FloatSize offset) {} // FIXME: This is used by ImageBufferAndroid, which should really be // managing the canvas lifecycle itself diff --git a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp index fcb78ed..03d2fb2 100644 --- a/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/fonts/FontAndroid.cpp @@ -218,8 +218,11 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, point.xy + [width, height, width, height, ...], so we have to convert */ - if (font->platformData().orientation() == Vertical) - y += SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent()); + if (font->platformData().orientation() == Vertical) { + float yOffset = SkFloatToScalar(font->fontMetrics().floatAscent(IdeographicBaseline) - font->fontMetrics().floatAscent()); + gc->platformContext()->setTextOffset(FloatSize(0.0f, -yOffset)); // compensate for offset in bounds calculation + y += yOffset; + } if (EmojiFont::IsAvailable()) { // set filtering, to make scaled images look nice(r) @@ -272,6 +275,9 @@ void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font, if (font->platformData().orientation() == Vertical) canvas->restore(); } + + if (font->platformData().orientation() == Vertical) + gc->platformContext()->setTextOffset(FloatSize()); // reset to undo above } void Font::drawEmphasisMarksForComplexText(WebCore::GraphicsContext*, WebCore::TextRun const&, WTF::AtomicString const&, WebCore::FloatPoint const&, int, int) const diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp index 84ce910..a652d3e 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp @@ -211,9 +211,9 @@ LayerAndroid::~LayerAndroid() #endif } -bool LayerAndroid::hasText() +float LayerAndroid::maxZoomScale() const { - return m_content && m_content->hasText(); + return m_content ? m_content->maxZoomScale() : 1.0f; } static int gDebugNbAnims = 0; diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h index 5a1ef57..6c2e43d 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h @@ -262,7 +262,7 @@ public: LayerType type() { return m_type; } virtual SubclassType subclassType() const { return LayerAndroid::StandardLayer; } - bool hasText(); + float maxZoomScale() const; void copyAnimationStartTimesRecursive(LayerAndroid* oldTree); diff --git a/Source/WebCore/platform/graphics/android/layers/LayerContent.h b/Source/WebCore/platform/graphics/android/layers/LayerContent.h index a18e4c8..b6714ba 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerContent.h +++ b/Source/WebCore/platform/graphics/android/layers/LayerContent.h @@ -45,7 +45,7 @@ public: bool isEmpty() { return !width() || !height(); } virtual void setCheckForOptimisations(bool check) = 0; virtual void checkForOptimisations() = 0; - virtual bool hasText() = 0; + virtual float maxZoomScale() = 0; virtual void draw(SkCanvas* canvas) = 0; virtual PrerenderedInval* prerenderForRect(const IntRect& dirty) { return 0; } virtual void clearPrerenders() { }; diff --git a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp index e40c9b6..bfd477e 100644 --- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp +++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.cpp @@ -48,13 +48,13 @@ int PictureLayerContent::height() void PictureLayerContent::checkForOptimisations() { if (!m_checkedContent) - hasText(); // for now only check the presence of text + maxZoomScale(); // for now only check the maximum scale for painting } -bool PictureLayerContent::hasText() +float PictureLayerContent::maxZoomScale() { if (m_checkedContent) - return m_hasText; + return m_hasText ? 1e6 : 1.0; // Let's check if we have text or not. If we don't, we can limit // ourselves to scale 1! @@ -76,7 +76,7 @@ bool PictureLayerContent::hasText() m_checkedContent = true; - return m_hasText; + return m_hasText ? 1e6 : 1.0; } void PictureLayerContent::draw(SkCanvas* canvas) diff --git a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h index cf633cb..e5181a5 100644 --- a/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h +++ b/Source/WebCore/platform/graphics/android/layers/PictureLayerContent.h @@ -40,7 +40,7 @@ public: virtual int height(); virtual void setCheckForOptimisations(bool check) { m_checkedContent = !check; } virtual void checkForOptimisations(); - virtual bool hasText(); + virtual float maxZoomScale(); virtual void draw(SkCanvas* canvas); virtual void serialize(SkWStream* stream); diff --git a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp index 1167bda..e48751d 100644 --- a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp +++ b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.cpp @@ -12,7 +12,7 @@ namespace WebCore { PicturePileLayerContent::PicturePileLayerContent(const PicturePile& picturePile) : m_picturePile(picturePile) - , m_hasText(picturePile.hasText()) + , m_maxZoomScale(picturePile.maxZoomScale()) , m_hasContent(!picturePile.isEmpty()) { } diff --git a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h index 9f3a263..cbaebed 100644 --- a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h +++ b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h @@ -41,7 +41,7 @@ public: virtual void setCheckForOptimisations(bool check) {} virtual void checkForOptimisations() {} // already performed, stored in m_hasText/m_hasContent - virtual bool hasText() { return m_hasText; } + virtual float maxZoomScale() { return m_maxZoomScale; } virtual void draw(SkCanvas* canvas); virtual void serialize(SkWStream* stream); virtual PrerenderedInval* prerenderForRect(const IntRect& dirty); @@ -50,7 +50,7 @@ public: private: PicturePile m_picturePile; - bool m_hasText; + float m_maxZoomScale; bool m_hasContent; }; diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp index 96a4a16..6caf93b 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp @@ -52,7 +52,7 @@ namespace WebCore { Surface::Surface() : m_surfaceBacking(0) , m_needsTexture(false) - , m_hasText(false) + , m_maxZoomScale(1) { #ifdef DEBUG_COUNT ClassTracker::instance()->increment("Surface"); @@ -140,7 +140,7 @@ void Surface::addLayer(LayerAndroid* layer, const TransformationMatrix& transfor SkSafeRef(layer); m_needsTexture |= layer->needsTexture(); - m_hasText |= layer->hasText(); + m_maxZoomScale = std::max(m_maxZoomScale, layer->maxZoomScale()); // add this layer's size to the surface's area // TODO: handle scale/3d transform mapping @@ -211,7 +211,6 @@ void Surface::prepareGL(bool layerTilesDisabled, bool updateWithBlit) if (tilesDisabled) { m_surfaceBacking->discardTextures(); } else { - bool allowZoom = hasText(); // only allow for scale > 1 if painting vectors IntRect prepareArea = computePrepareArea(); IntRect fullArea = fullContentArea(); @@ -223,7 +222,7 @@ void Surface::prepareGL(bool layerTilesDisabled, bool updateWithBlit) prepareArea.x(), prepareArea.y(), prepareArea.width(), prepareArea.height(), fullArea.x(), fullArea.y(), fullArea.width(), fullArea.height()); - m_surfaceBacking->prepareGL(getFirstLayer()->state(), allowZoom, + m_surfaceBacking->prepareGL(getFirstLayer()->state(), m_maxZoomScale, prepareArea, fullArea, this, useAggressiveRendering(), updateWithBlit); } diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.h b/Source/WebCore/platform/graphics/android/rendering/Surface.h index f9f38e6..654d7bf 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.h +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.h @@ -61,7 +61,6 @@ public: LayerAndroid* getFirstLayer() const { return m_layers[0]; } bool needsTexture() { return m_needsTexture; } - bool hasText() { return m_hasText; } bool isBase(); // don't allow transform fudging for merged layers - they need the transform @@ -87,7 +86,7 @@ private: SurfaceBacking* m_surfaceBacking; bool m_needsTexture; - bool m_hasText; + float m_maxZoomScale; Vector<LayerAndroid*> m_layers; Color m_background; diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp index 5b11df6..d7b904f 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.cpp @@ -46,7 +46,7 @@ SurfaceBacking::SurfaceBacking(bool isBaseSurface) , m_scale(-1) , m_futureScale(-1) , m_zooming(false) - , m_hasAllowedZoom(false) + , m_maxZoomScale(1) { #ifdef DEBUG_COUNT @@ -64,7 +64,7 @@ SurfaceBacking::~SurfaceBacking() #endif } -void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom, +void SurfaceBacking::prepareGL(GLWebViewState* state, float maxZoomScale, const IntRect& prepareArea, const IntRect& fullContentArea, TilePainter* painter, bool aggressiveRendering, bool updateWithBlit) @@ -72,11 +72,11 @@ void SurfaceBacking::prepareGL(GLWebViewState* state, bool allowZoom, // If the surface backing has ever zoomed beyond 1.0 scale, it's always // allowed to (so repaints aren't necessary when allowZoom toggles). If not, // and allowZoom is false, don't allow scale greater than 1.0 - m_hasAllowedZoom |= allowZoom; + m_maxZoomScale = std::max(m_maxZoomScale, maxZoomScale); float scale = state->scale(); bool scaleOverridden = false; - if (scale > 1 && !m_hasAllowedZoom) { - scale = 1; + if (scale > m_maxZoomScale) { + scale = m_maxZoomScale; scaleOverridden = true; } diff --git a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h index 80c6545..ff866bf 100644 --- a/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h +++ b/Source/WebCore/platform/graphics/android/rendering/SurfaceBacking.h @@ -40,7 +40,7 @@ class SurfaceBacking : public SkRefCnt { public: SurfaceBacking(bool isBaseSurface); ~SurfaceBacking(); - void prepareGL(GLWebViewState* state, bool allowZoom, + void prepareGL(GLWebViewState* state, float maxZoomScale, const IntRect& prepareArea, const IntRect& fullContentArea, TilePainter* painter, bool aggressiveRendering, bool updateWithBlit); @@ -95,7 +95,7 @@ private: float m_futureScale; double m_zoomUpdateTime; bool m_zooming; - bool m_hasAllowedZoom; + float m_maxZoomScale; }; } // namespace WebCore |