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

Commit abedc7dd authored by Kevin Lubick's avatar Kevin Lubick Committed by Android (Google) Code Review
Browse files

Merge "Migrate SkImage static methods to SkImages namespace"

parents 30285957 dd8b2ea5
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#include "AutoBackendTextureRelease.h"

#include <SkImage.h>
#include <include/gpu/ganesh/SkImageGanesh.h>
#include "renderthread/RenderThread.h"
#include "utils/Color.h"
#include "utils/PaintUtils.h"
@@ -83,10 +85,10 @@ void AutoBackendTextureRelease::makeImage(AHardwareBuffer* buffer,
    AHardwareBuffer_describe(buffer, &desc);
    SkColorType colorType = GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(desc.format);
    // The following ref will be counteracted by Skia calling releaseProc, either during
    // MakeFromTexture if there is a failure, or later when SkImage is discarded. It must
    // be called before MakeFromTexture, otherwise Skia may remove HWUI's ref on failure.
    // BorrowTextureFrom if there is a failure, or later when SkImage is discarded. It must
    // be called before BorrowTextureFrom, otherwise Skia may remove HWUI's ref on failure.
    ref();
    mImage = SkImage::MakeFromTexture(
    mImage = SkImages::BorrowTextureFrom(
            context, mBackendTexture, kTopLeft_GrSurfaceOrigin, colorType, kPremul_SkAlphaType,
            uirenderer::DataSpaceToColorSpace(dataspace), releaseProc, this);
}
+3 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <SkBitmap.h>
#include <SkCanvas.h>
#include <SkImage.h>
#include <SkImageAndroid.h>
#include <SkImageInfo.h>
#include <SkRefCnt.h>
#include <gui/TraceUtils.h>
@@ -262,7 +263,8 @@ private:
          }

          sk_sp<SkImage> image =
              SkImage::MakeFromAHardwareBufferWithData(mGrContext.get(), bitmap.pixmap(), ahb);
              SkImages::TextureFromAHardwareBufferWithData(mGrContext.get(), bitmap.pixmap(),
                                                           ahb);
          mGrContext->submit(true);

          uploadSucceeded = (image.get() != nullptr);
+3 −1
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <SkCanvas.h>
#include <SkColorSpace.h>
#include <SkImage.h>
#include <SkImageAndroid.h>
#include <SkImageInfo.h>
#include <SkMatrix.h>
#include <SkPaint.h>
@@ -108,7 +109,8 @@ void Readback::copySurfaceInto(ANativeWindow* window, const std::shared_ptr<Copy
    sk_sp<SkColorSpace> colorSpace =
            DataSpaceToColorSpace(static_cast<android_dataspace>(dataspace));
    sk_sp<SkImage> image =
            SkImage::MakeFromAHardwareBuffer(sourceBuffer.get(), kPremul_SkAlphaType, colorSpace);
            SkImages::DeferredFromAHardwareBuffer(sourceBuffer.get(), kPremul_SkAlphaType, 
                                                  colorSpace);

    if (!image.get()) {
        return request->onCopyFinished(CopyResult::UnknownError);
+5 −3
Original line number Diff line number Diff line
@@ -39,8 +39,9 @@
#include <SkColor.h>
#include <SkEncodedImageFormat.h>
#include <SkHighContrastFilter.h>
#include <SkImageEncoder.h>
#include <SkImage.h>
#include <SkImageAndroid.h>
#include <SkImageEncoder.h>
#include <SkImagePriv.h>
#include <SkJpegGainmapEncoder.h>
#include <SkPixmap.h>
@@ -264,7 +265,8 @@ Bitmap::Bitmap(AHardwareBuffer* buffer, const SkImageInfo& info, size_t rowBytes
    mPixelStorage.hardware.buffer = buffer;
    AHardwareBuffer_acquire(buffer);
    setImmutable();  // HW bitmaps are always immutable
    mImage = SkImage::MakeFromAHardwareBuffer(buffer, mInfo.alphaType(), mInfo.refColorSpace());
    mImage = SkImages::DeferredFromAHardwareBuffer(buffer, mInfo.alphaType(),
                                                   mInfo.refColorSpace());
}
#endif

@@ -373,7 +375,7 @@ sk_sp<SkImage> Bitmap::makeImage() {
        // TODO: refactor Bitmap to not derive from SkPixelRef, which would allow caching here.
#ifdef __ANDROID__
        // pinnable images are only supported with the Ganesh GPU backend compiled in.
        image = sk_image_factory::MakePinnableFromRasterBitmap(skiaBitmap);
        image = SkImages::PinnableRasterFromBitmap(skiaBitmap);
#else
        image = SkMakeImageFromRasterBitmap(skiaBitmap, kNever_SkCopyPixelsMode);
#endif
+2 −2
Original line number Diff line number Diff line
@@ -473,7 +473,7 @@ public:
        // actually cross thread boundaries here, make a copy so it's immutable proper
        if (bitmap && !bitmap->isImmutable()) {
            ATRACE_NAME("Copying mutable bitmap");
            return SkImage::MakeFromBitmap(*bitmap);
            return SkImages::RasterFromBitmap(*bitmap);
        }
        if (img->isTextureBacked()) {
            ATRACE_NAME("Readback of texture image");
@@ -493,7 +493,7 @@ public:
                return sk_ref_sp(img);
            }
            bm.setImmutable();
            return sk_image_factory::MakePinnableFromRasterBitmap(bm);
            return SkImages::PinnableRasterFromBitmap(bm);
        }
        return sk_ref_sp(img);
    }
Loading