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

Commit c091e218 authored by Ben Wagner's avatar Ben Wagner Committed by Android (Google) Code Review
Browse files

Merge "Remove use of SkAutoSTMalloc from Android."

parents 0dcb9e81 6bbf68d0
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -487,13 +487,12 @@ void SkiaCanvas::drawPoints(const float* points, int count, const SkPaint& paint
                            SkCanvas::PointMode mode) {
    // convert the floats into SkPoints
    count >>= 1;    // now it is the number of points
    SkAutoSTMalloc<32, SkPoint> storage(count);
    SkPoint* pts = storage.get();
    std::unique_ptr<SkPoint[]> pts(new SkPoint[count]);
    for (int i = 0; i < count; i++) {
        pts[i].set(points[0], points[1]);
        points += 2;
    }
    mCanvas->drawPoints(mode, count, pts, paint);
    mCanvas->drawPoints(mode, count, pts.get(), paint);
}


@@ -605,7 +604,7 @@ void SkiaCanvas::drawBitmapMesh(const SkBitmap& bitmap, int meshWidth, int meshH
#ifndef SK_SCALAR_IS_FLOAT
    SkDEBUGFAIL("SkScalar must be a float for these conversions to be valid");
#endif
    SkAutoMalloc storage(storageSize);
    std::unique_ptr<char[]> storage(new char[storageSize]);
    SkPoint* texs = (SkPoint*)storage.get();
    uint16_t* indices = (uint16_t*)(texs + ptCount);

+14 −11
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#include <SkRect.h>
#include <SkRRect.h>

#include <memory>

namespace android {
namespace uirenderer {

@@ -216,7 +218,8 @@ public:
            glyphIDs = (uint16_t*)text;
            count = byteLength >> 1;
        } else {
            storage.reset(byteLength); // ensures space for one glyph per ID given UTF8 encoding.
             // ensure space for one glyph per ID given UTF8 encoding.
            storage.reset(new uint16_t[byteLength]);
            glyphIDs = storage.get();
            count = paint.textToGlyphs(text, byteLength, storage.get());
            paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
@@ -227,7 +230,7 @@ public:
    uint16_t* glyphIDs;
    int count;
private:
    SkAutoSTMalloc<32, uint16_t> storage;
    std::unique_ptr<uint16_t[]> storage;
};

void SkiaCanvasProxy::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
@@ -236,8 +239,8 @@ void SkiaCanvasProxy::onDrawText(const void* text, size_t byteLength, SkScalar x
    GlyphIDConverter glyphs(text, byteLength, origPaint);

    // compute the glyph positions
    SkAutoSTMalloc<32, SkPoint> pointStorage(glyphs.count);
    SkAutoSTMalloc<32, SkScalar> glyphWidths(glyphs.count);
    std::unique_ptr<SkPoint[]> pointStorage(new SkPoint[glyphs.count]);
    std::unique_ptr<SkScalar[]> glyphWidths(new SkScalar[glyphs.count]);
    glyphs.paint.getTextWidths(glyphs.glyphIDs, glyphs.count << 1, glyphWidths.get());

    // compute conservative bounds
@@ -296,7 +299,7 @@ void SkiaCanvasProxy::onDrawPosText(const void* text, size_t byteLength, const S
    // convert to relative positions if necessary
    int x, y;
    const SkPoint* posArray;
    SkAutoSTMalloc<32, SkPoint> pointStorage;
    std::unique_ptr<SkPoint[]> pointStorage;
    if (mCanvas->drawTextAbsolutePos()) {
        x = 0;
        y = 0;
@@ -304,11 +307,12 @@ void SkiaCanvasProxy::onDrawPosText(const void* text, size_t byteLength, const S
    } else {
        x = pos[0].fX;
        y = pos[0].fY;
        posArray = pointStorage.reset(glyphs.count);
        pointStorage.reset(new SkPoint[glyphs.count]);
        for (int i = 0; i < glyphs.count; i++) {
            pointStorage[i].fX = pos[i].fX - x;
            pointStorage[i].fY = pos[i].fY - y;
        }
        posArray = pointStorage.get();
    }

    // compute conservative bounds
@@ -326,12 +330,11 @@ void SkiaCanvasProxy::onDrawPosText(const void* text, size_t byteLength, const S
void SkiaCanvasProxy::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
        SkScalar constY, const SkPaint& paint) {
    const size_t pointCount = byteLength >> 1;
    SkAutoSTMalloc<32, SkPoint> storage(pointCount);
    SkPoint* pts = storage.get();
    std::unique_ptr<SkPoint[]> pts(new SkPoint[pointCount]);
    for (size_t i = 0; i < pointCount; i++) {
        pts[i].set(xpos[i], constY);
    }
    this->onDrawPosText(text, byteLength, pts, paint);
    this->onDrawPosText(text, byteLength, pts.get(), paint);
}

void SkiaCanvasProxy::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,