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

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

Merge "Replace SkAutoTUnref with sk_sp."

parents 9c1202be 18bd8853
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ int main(int argc, char** argv)
        if (png) {
            const SkImageInfo info = SkImageInfo::Make(w, h, flinger2skia(f),
                                                       kPremul_SkAlphaType);
            SkAutoTUnref<SkData> data(SkImageEncoder::EncodeData(info, base, s*bytesPerPixel(f),
            sk_sp<SkData> data(SkImageEncoder::EncodeData(info, base, s*bytesPerPixel(f),
                    SkImageEncoder::kPNG_Type, SkImageEncoder::kDefaultQuality));
            if (data.get()) {
                write(fd, data->data(), data->size());
+2 −2
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
    SkColorType decodeColorType = codec->computeOutputColorType(prefColorType);

    // Construct a color table for the decode if necessary
    SkAutoTUnref<SkColorTable> colorTable(nullptr);
    sk_sp<SkColorTable> colorTable(nullptr);
    SkPMColor* colorPtr = nullptr;
    int* colorCount = nullptr;
    int maxColors = 256;
@@ -399,7 +399,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
    }
    SkBitmap decodingBitmap;
    if (!decodingBitmap.setInfo(bitmapInfo) ||
            !decodingBitmap.tryAllocPixels(decodeAllocator, colorTable)) {
            !decodingBitmap.tryAllocPixels(decodeAllocator, colorTable.get())) {
        // SkAndroidCodec should recommend a valid SkImageInfo, so setInfo()
        // should only only fail if the calculated value for rowBytes is too
        // large.
+5 −3
Original line number Diff line number Diff line
@@ -39,18 +39,20 @@
#include <jni.h>
#include <sys/stat.h>

#include <memory>

using namespace android;

static jobject createBitmapRegionDecoder(JNIEnv* env, std::unique_ptr<SkStreamRewindable> stream) {
    SkAutoTDelete<SkBitmapRegionDecoder> brd(
  std::unique_ptr<SkBitmapRegionDecoder> brd(
            SkBitmapRegionDecoder::Create(stream.release(),
                                          SkBitmapRegionDecoder::kAndroidCodec_Strategy));
    if (NULL == brd) {
    if (!brd) {
        doThrowIOE(env, "Image format not supported");
        return nullObjectReturn("CreateBitmapRegionDecoder returned null");
    }

    return GraphicsJNI::createBitmapRegionDecoder(env, brd.detach());
    return GraphicsJNI::createBitmapRegionDecoder(env, brd.release());
}

static jobject nativeNewInstanceFromByteArray(JNIEnv* env, jobject, jbyteArray byteArray,
+3 −3
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ static jboolean FontFamily_addFont(JNIEnv* env, jobject clazz, jlong familyPtr,
    SkFontMgr::FontParameters params;
    params.setCollectionIndex(ttcIndex);

    SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
    sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
    sk_sp<SkTypeface> face(fm->createFromStream(fontData.release(), params));
    if (face == NULL) {
        ALOGE("addFont failed to create font");
@@ -172,7 +172,7 @@ static jboolean FontFamily_addFontWeightStyle(JNIEnv* env, jobject clazz, jlong
    params.setCollectionIndex(ttcIndex);
    params.setAxes(skiaAxes.get(), skiaAxesLength);

    SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
    sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
    sk_sp<SkTypeface> face(fm->createFromStream(fontData.release(), params));
    if (face == NULL) {
        ALOGE("addFont failed to create font, invalid request");
@@ -216,7 +216,7 @@ static jboolean FontFamily_addFontFromAsset(JNIEnv* env, jobject, jlong familyPt
    sk_sp<SkData> data(SkData::MakeWithProc(buf, asset->getLength(), releaseAsset, asset));
    std::unique_ptr<SkStreamAsset> fontData(new SkMemoryStream(std::move(data)));

    SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
    sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
    sk_sp<SkTypeface> face(fm->createFromStream(fontData.release(), SkFontMgr::FontParameters()));
    if (face == NULL) {
        ALOGE("addFontFromAsset failed to create font %s", str.c_str());
+3 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ static jlong Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle, j
    // The current shader will no longer need a direct reference owned by Shader.java
    // as all the data needed is contained within the newly created LocalMatrixShader.
    SkASSERT(shaderHandle);
    SkAutoTUnref<SkShader> currentShader(reinterpret_cast<SkShader*>(shaderHandle));
    sk_sp<SkShader> currentShader(reinterpret_cast<SkShader*>(shaderHandle));

    // Attempt to peel off an existing proxy shader and get the proxy's matrix. If
    // the proxy existed and it's matrix equals the desired matrix then just return
@@ -74,10 +74,10 @@ static jlong Shader_setLocalMatrix(JNIEnv* env, jobject o, jlong shaderHandle, j
    //          API enforces that all local matrices are set using this call and
    //          not passed to the constructor of the Shader.
    SkMatrix proxyMatrix;
    SkAutoTUnref<SkShader> baseShader(currentShader->refAsALocalMatrixShader(&proxyMatrix));
    sk_sp<SkShader> baseShader = currentShader->makeAsALocalMatrixShader(&proxyMatrix);
    if (baseShader.get()) {
        if (proxyMatrix == *matrix) {
            return reinterpret_cast<jlong>(currentShader.detach());
            return reinterpret_cast<jlong>(currentShader.release());
        }
        return reinterpret_cast<jlong>(baseShader->makeWithLocalMatrix(*matrix).release());
    }
Loading