Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 624234f6 authored by Romain Guy's avatar Romain Guy
Browse files

Take only the scale params into account to rasterize text

This change extracts the scale parameters of the current transform
to pass then to the font renderer. Rotation and perspective are
applied to the generated mesh inside the vertex shader. This limits
the number of glyphs we have to create in the font cache and thus
reduces memory churn.

Change-Id: Ic5b3bae2b2b0e0250a8ee723b071a1709725c749
parent 0b58a3de
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1175,8 +1175,8 @@ public:
        SkPaint* paint = getPaint(renderer);
        FontRenderer& fontRenderer = renderer.getCaches().fontRenderer->getFontRenderer(paint);
        const bool pureTranslate = state.mMatrix.isPureTranslate();
        fontRenderer.precache(paint, mText, mCount,
                pureTranslate ? mat4::identity() : state.mMatrix);
        const mat4 transform = renderer.findBestFontTransform(state.mMatrix);
        fontRenderer.precache(paint, mText, mCount, transform);
    }

    virtual status_t applyDraw(OpenGLRenderer& renderer, Rect& dirty, uint32_t level,
+4 −4
Original line number Diff line number Diff line
@@ -92,11 +92,11 @@ void LayerRenderer::finish() {
    // who will invoke OpenGLRenderer::resume()
}

GLint LayerRenderer::getTargetFbo() {
GLint LayerRenderer::getTargetFbo() const {
    return mLayer->getFbo();
}

bool LayerRenderer::suppressErrorChecks() {
bool LayerRenderer::suppressErrorChecks() const {
    return true;
}

@@ -104,7 +104,7 @@ bool LayerRenderer::suppressErrorChecks() {
// Layer support
///////////////////////////////////////////////////////////////////////////////

bool LayerRenderer::hasLayer() {
bool LayerRenderer::hasLayer() const {
    return true;
}

@@ -116,7 +116,7 @@ void LayerRenderer::ensureStencilBuffer() {
// Dirty region tracking
///////////////////////////////////////////////////////////////////////////////

Region* LayerRenderer::getRegion() {
Region* LayerRenderer::getRegion() const {
    if (getSnapshot()->flags & Snapshot::kFlagFboTarget) {
        return OpenGLRenderer::getRegion();
    }
+4 −4
Original line number Diff line number Diff line
@@ -65,10 +65,10 @@ public:

protected:
    virtual void ensureStencilBuffer();
    virtual bool hasLayer();
    virtual Region* getRegion();
    virtual GLint getTargetFbo();
    virtual bool suppressErrorChecks();
    virtual bool hasLayer() const;
    virtual Region* getRegion() const;
    virtual GLint getTargetFbo() const;
    virtual bool suppressErrorChecks() const;

private:
    void generateMesh();
+2 −2
Original line number Diff line number Diff line
@@ -232,11 +232,11 @@ void Matrix4::copyTo(float* v) const {
    memcpy(v, data, sizeof(data));
}

float Matrix4::getTranslateX() {
float Matrix4::getTranslateX() const {
    return data[kTranslateX];
}

float Matrix4::getTranslateY() {
float Matrix4::getTranslateY() const {
    return data[kTranslateY];
}

+2 −2
Original line number Diff line number Diff line
@@ -161,8 +161,8 @@ public:
    void mapRect(Rect& r) const;
    void mapPoint(float& x, float& y) const;

    float getTranslateX();
    float getTranslateY();
    float getTranslateX() const;
    float getTranslateY() const;

    void decomposeScale(float& sx, float& sy) const;

Loading