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

Commit a22c1307 authored by Kevin Lubick's avatar Kevin Lubick
Browse files

Remove SkAutoSTMalloc and other private Skia functions

Bug: skbug.com/13983
Change-Id: I094a0ae69653d428f2c47d1fdbb2cd32def9a347
parent 1f623994
Loading
Loading
Loading
Loading
+15 −11
Original line number Original line Diff line number Diff line
@@ -19,6 +19,8 @@
#include <SkAndroidFrameworkUtils.h>
#include <SkAndroidFrameworkUtils.h>
#include <SkAnimatedImage.h>
#include <SkAnimatedImage.h>
#include <SkBitmap.h>
#include <SkBitmap.h>
#include <SkBlendMode.h>
#include <SkCanvas.h>
#include <SkCanvasPriv.h>
#include <SkCanvasPriv.h>
#include <SkCanvasStateUtils.h>
#include <SkCanvasStateUtils.h>
#include <SkColorFilter.h>
#include <SkColorFilter.h>
@@ -35,7 +37,6 @@
#include <SkRect.h>
#include <SkRect.h>
#include <SkRefCnt.h>
#include <SkRefCnt.h>
#include <SkShader.h>
#include <SkShader.h>
#include <SkTemplates.h>
#include <SkTextBlob.h>
#include <SkTextBlob.h>
#include <SkVertices.h>
#include <SkVertices.h>


@@ -45,13 +46,14 @@


#include "CanvasProperty.h"
#include "CanvasProperty.h"
#include "NinePatchUtils.h"
#include "NinePatchUtils.h"
#include "SkBlendMode.h"
#include "VectorDrawable.h"
#include "VectorDrawable.h"
#include "hwui/Bitmap.h"
#include "hwui/Bitmap.h"
#include "hwui/MinikinUtils.h"
#include "hwui/MinikinUtils.h"
#include "hwui/PaintFilter.h"
#include "hwui/PaintFilter.h"
#include <log/log.h>
#include "pipeline/skia/AnimatedDrawables.h"
#include "pipeline/skia/AnimatedDrawables.h"
#include "pipeline/skia/HolePunch.h"
#include "pipeline/skia/HolePunch.h"
#include <ui/FatVector.h>


namespace android {
namespace android {


@@ -248,7 +250,7 @@ const SkiaCanvas::SaveRec* SkiaCanvas::currentSaveRec() const {
                                 ? static_cast<const SaveRec*>(&mSaveStack->back())
                                 ? static_cast<const SaveRec*>(&mSaveStack->back())
                                 : nullptr;
                                 : nullptr;
    int currentSaveCount = mCanvas->getSaveCount();
    int currentSaveCount = mCanvas->getSaveCount();
    SkASSERT(!rec || currentSaveCount >= rec->saveCount);
    LOG_FATAL_IF(!(!rec || currentSaveCount >= rec->saveCount));


    return (rec && rec->saveCount == currentSaveCount) ? rec : nullptr;
    return (rec && rec->saveCount == currentSaveCount) ? rec : nullptr;
}
}
@@ -298,7 +300,7 @@ void SkiaCanvas::recordClip(const T& clip, SkClipOp op) {


// Applies and optionally removes all clips >= index.
// Applies and optionally removes all clips >= index.
void SkiaCanvas::applyPersistentClips(size_t clipStartIndex) {
void SkiaCanvas::applyPersistentClips(size_t clipStartIndex) {
    SkASSERT(clipStartIndex <= mClipStack.size());
    LOG_FATAL_IF(clipStartIndex > mClipStack.size());
    const auto begin = mClipStack.cbegin() + clipStartIndex;
    const auto begin = mClipStack.cbegin() + clipStartIndex;
    const auto end = mClipStack.cend();
    const auto end = mClipStack.cend();


@@ -646,7 +648,7 @@ void SkiaCanvas::drawBitmapMesh(Bitmap& bitmap, int meshWidth, int meshHeight,
            texsPtr += 1;
            texsPtr += 1;
            y += dy;
            y += dy;
        }
        }
        SkASSERT(texsPtr - texs == ptCount);
        LOG_FATAL_IF((texsPtr - texs) != ptCount);
    }
    }


    // cons up indices
    // cons up indices
@@ -669,14 +671,14 @@ void SkiaCanvas::drawBitmapMesh(Bitmap& bitmap, int meshWidth, int meshHeight,
            // bump to the next row
            // bump to the next row
            index += 1;
            index += 1;
        }
        }
        SkASSERT(indexPtr - indices == indexCount);
        LOG_FATAL_IF((indexPtr - indices) != indexCount);
    }
    }


// double-check that we have legal indices
// double-check that we have legal indices
#ifdef SK_DEBUG
#if !defined(NDEBUG)
    {
    {
        for (int i = 0; i < indexCount; i++) {
        for (int i = 0; i < indexCount; i++) {
            SkASSERT((unsigned)indices[i] < (unsigned)ptCount);
            LOG_FATAL_IF((unsigned)indices[i] >= (unsigned)ptCount);
        }
        }
    }
    }
#endif
#endif
@@ -718,10 +720,12 @@ void SkiaCanvas::drawNinePatch(Bitmap& bitmap, const Res_png_9patch& chunk, floa
        numFlags = (lattice.fXCount + 1) * (lattice.fYCount + 1);
        numFlags = (lattice.fXCount + 1) * (lattice.fYCount + 1);
    }
    }


    SkAutoSTMalloc<25, SkCanvas::Lattice::RectType> flags(numFlags);
    // Most times, we do not have very many flags/colors, so the stack allocated part of
    SkAutoSTMalloc<25, SkColor> colors(numFlags);
    // FatVector will save us a heap allocation.
    FatVector<SkCanvas::Lattice::RectType, 25> flags(numFlags);
    FatVector<SkColor, 25> colors(numFlags);
    if (numFlags > 0) {
    if (numFlags > 0) {
        NinePatchUtils::SetLatticeFlags(&lattice, flags.get(), numFlags, chunk, colors.get());
        NinePatchUtils::SetLatticeFlags(&lattice, flags.data(), numFlags, chunk, colors.data());
    }
    }


    lattice.fBounds = nullptr;
    lattice.fBounds = nullptr;
+8 −5
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


#include "SkiaRecordingCanvas.h"
#include "SkiaRecordingCanvas.h"
#include "hwui/Paint.h"
#include "hwui/Paint.h"
#include <include/private/SkTemplates.h> // SkAutoSTMalloc
#include <SkBlendMode.h>
#include <SkBlendMode.h>
#include <SkData.h>
#include <SkData.h>
#include <SkDrawable.h>
#include <SkDrawable.h>
@@ -43,6 +42,8 @@
#include "pipeline/skia/VkFunctorDrawable.h"
#include "pipeline/skia/VkFunctorDrawable.h"
#include "pipeline/skia/VkInteropFunctorDrawable.h"
#include "pipeline/skia/VkInteropFunctorDrawable.h"
#endif
#endif
#include <log/log.h>
#include <ui/FatVector.h>


namespace android {
namespace android {
namespace uirenderer {
namespace uirenderer {
@@ -55,7 +56,7 @@ namespace skiapipeline {
void SkiaRecordingCanvas::initDisplayList(uirenderer::RenderNode* renderNode, int width,
void SkiaRecordingCanvas::initDisplayList(uirenderer::RenderNode* renderNode, int width,
                                          int height) {
                                          int height) {
    mCurrentBarrier = nullptr;
    mCurrentBarrier = nullptr;
    SkASSERT(mDisplayList.get() == nullptr);
    LOG_FATAL_IF(mDisplayList.get() != nullptr);


    if (renderNode) {
    if (renderNode) {
        mDisplayList = renderNode->detachAvailableList();
        mDisplayList = renderNode->detachAvailableList();
@@ -285,10 +286,12 @@ void SkiaRecordingCanvas::drawNinePatch(Bitmap& bitmap, const Res_png_9patch& ch
        numFlags = (lattice.fXCount + 1) * (lattice.fYCount + 1);
        numFlags = (lattice.fXCount + 1) * (lattice.fYCount + 1);
    }
    }


    SkAutoSTMalloc<25, SkCanvas::Lattice::RectType> flags(numFlags);
    // Most times, we do not have very many flags/colors, so the stack allocated part of
    SkAutoSTMalloc<25, SkColor> colors(numFlags);
    // FatVector will save us a heap allocation.
    FatVector<SkCanvas::Lattice::RectType, 25> flags(numFlags);
    FatVector<SkColor, 25> colors(numFlags);
    if (numFlags > 0) {
    if (numFlags > 0) {
        NinePatchUtils::SetLatticeFlags(&lattice, flags.get(), numFlags, chunk, colors.get());
        NinePatchUtils::SetLatticeFlags(&lattice, flags.data(), numFlags, chunk, colors.data());
    }
    }


    lattice.fBounds = nullptr;
    lattice.fBounds = nullptr;