Remove GPU-related calls from SkImage.h when !SK_SUPPORT_GPU
Change-Id: Icf6f45069b078f7936cfa08224fd8796d8c283b4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/464122 Commit-Queue: Kevin Lubick <kjlubick@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
1c51867540
commit
146cfcc042
@ -8,6 +8,12 @@ Milestone 97
|
||||
internally (versus querying specific modifier support). Clients can either pass a flag to Vulkan
|
||||
GrBackendFormat to say it uses modifiers or pass the VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT
|
||||
to a GrBackendTexture via the GrVkImageInfo struct.
|
||||
* The following functions and methods are not defined in SkImage when SK_SUPPORT_GPU is 0:
|
||||
MakeTextureFromCompressed, MakeFromTexture, MakeFromCompressedTexture,
|
||||
MakeCrossContextFromPixmap, MakeFromAdoptedTexture, MakeFromYUVATextures,
|
||||
MakeFromYUVAPixmaps, MakePromiseTexture, MakePromiseYUVATexture, MakeBackendTextureFromSkImage,
|
||||
flush, flushAndSubmit, getBackendTexture, makeTextureImage.
|
||||
These were all no-ops anyway when just the CPU backend was compiled in.
|
||||
|
||||
* * *
|
||||
|
||||
|
@ -16,7 +16,9 @@
|
||||
#include "include/core/SkScalar.h"
|
||||
#include "include/core/SkShader.h"
|
||||
#include "include/core/SkTileMode.h"
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "include/gpu/GrTypes.h"
|
||||
#endif
|
||||
#include <functional> // std::function
|
||||
|
||||
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
|
||||
@ -207,7 +209,47 @@ public:
|
||||
|
||||
static const CompressionType kETC1_CompressionType = CompressionType::kETC2_RGB8_UNORM;
|
||||
|
||||
/** Creates a GPU-backed SkImage from compressed data.
|
||||
/** Creates a CPU-backed SkImage from compressed data.
|
||||
|
||||
This method will decompress the compressed data and create an image wrapping
|
||||
it. Any mipmap levels present in the compressed data are discarded.
|
||||
|
||||
@param data compressed data to store in SkImage
|
||||
@param width width of full SkImage
|
||||
@param height height of full SkImage
|
||||
@param type type of compression used
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeRasterFromCompressed(sk_sp<SkData> data,
|
||||
int width, int height,
|
||||
CompressionType type);
|
||||
|
||||
enum class BitDepth {
|
||||
kU8, //!< uses 8-bit unsigned int per color component
|
||||
kF16, //!< uses 16-bit float per color component
|
||||
};
|
||||
|
||||
/** Creates SkImage from picture. Returned SkImage width and height are set by dimensions.
|
||||
SkImage draws picture with matrix and paint, set to bitDepth and colorSpace.
|
||||
|
||||
If matrix is nullptr, draws with identity SkMatrix. If paint is nullptr, draws
|
||||
with default SkPaint. colorSpace may be nullptr.
|
||||
|
||||
@param picture stream of drawing commands
|
||||
@param dimensions width and height
|
||||
@param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
|
||||
@param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
|
||||
@param bitDepth 8-bit integer or 16-bit float: per component
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
|
||||
const SkMatrix* matrix, const SkPaint* paint,
|
||||
BitDepth bitDepth,
|
||||
sk_sp<SkColorSpace> colorSpace);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/** Creates a GPU-backed SkImage from compressed data.
|
||||
|
||||
This method will return an SkImage representing the compressed data.
|
||||
If the GPU doesn't support the specified compression method, the data
|
||||
@ -232,21 +274,6 @@ public:
|
||||
GrMipmapped mipMapped = GrMipmapped::kNo,
|
||||
GrProtected isProtected = GrProtected::kNo);
|
||||
|
||||
/** Creates a CPU-backed SkImage from compressed data.
|
||||
|
||||
This method will decompress the compressed data and create an image wrapping
|
||||
it. Any mipmap levels present in the compressed data are discarded.
|
||||
|
||||
@param data compressed data to store in SkImage
|
||||
@param width width of full SkImage
|
||||
@param height height of full SkImage
|
||||
@param type type of compression used
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeRasterFromCompressed(sk_sp<SkData> data,
|
||||
int width, int height,
|
||||
CompressionType type);
|
||||
|
||||
/** User function called when supplied texture may be deleted.
|
||||
*/
|
||||
typedef void (*TextureReleaseProc)(ReleaseContext releaseContext);
|
||||
@ -417,71 +444,14 @@ public:
|
||||
GrMipMapped buildMips = GrMipmapped::kNo,
|
||||
bool limitToMaxTextureSize = false,
|
||||
sk_sp<SkColorSpace> imageColorSpace = nullptr);
|
||||
|
||||
enum class BitDepth {
|
||||
kU8, //!< uses 8-bit unsigned int per color component
|
||||
kF16, //!< uses 16-bit float per color component
|
||||
};
|
||||
|
||||
/** Creates SkImage from picture. Returned SkImage width and height are set by dimensions.
|
||||
SkImage draws picture with matrix and paint, set to bitDepth and colorSpace.
|
||||
|
||||
If matrix is nullptr, draws with identity SkMatrix. If paint is nullptr, draws
|
||||
with default SkPaint. colorSpace may be nullptr.
|
||||
|
||||
@param picture stream of drawing commands
|
||||
@param dimensions width and height
|
||||
@param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
|
||||
@param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
|
||||
@param bitDepth 8-bit integer or 16-bit float: per component
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
|
||||
const SkMatrix* matrix, const SkPaint* paint,
|
||||
BitDepth bitDepth,
|
||||
sk_sp<SkColorSpace> colorSpace);
|
||||
|
||||
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
|
||||
/** (See Skia bug 7447)
|
||||
Creates SkImage from Android hardware buffer.
|
||||
Returned SkImage takes a reference on the buffer.
|
||||
|
||||
Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
|
||||
|
||||
@param hardwareBuffer AHardwareBuffer Android hardware buffer
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeFromAHardwareBuffer(
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
SkAlphaType alphaType = kPremul_SkAlphaType,
|
||||
sk_sp<SkColorSpace> colorSpace = nullptr,
|
||||
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
||||
|
||||
/** Creates SkImage from Android hardware buffer and uploads the data from the SkPixmap to it.
|
||||
Returned SkImage takes a reference on the buffer.
|
||||
|
||||
Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
|
||||
|
||||
@param context GPU context
|
||||
@param pixmap SkPixmap that contains data to be uploaded to the AHardwareBuffer
|
||||
@param hardwareBuffer AHardwareBuffer Android hardware buffer
|
||||
@param surfaceOrigin surface origin for resulting image
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeFromAHardwareBufferWithData(
|
||||
GrDirectContext* context,
|
||||
const SkPixmap& pixmap,
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
||||
#endif
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
using PromiseImageTextureContext = void*;
|
||||
using PromiseImageTextureFulfillProc =
|
||||
sk_sp<SkPromiseImageTexture> (*)(PromiseImageTextureContext);
|
||||
using PromiseImageTextureReleaseProc = void (*)(PromiseImageTextureContext);
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/** Create a new SkImage that is very similar to an SkImage created by MakeFromTexture. The
|
||||
difference is that the caller need not have created the texture nor populated it with the
|
||||
image pixel data. Moreover, the SkImage may be created on a thread as the creation of the
|
||||
@ -554,6 +524,43 @@ public:
|
||||
PromiseImageTextureReleaseProc textureReleaseProc,
|
||||
PromiseImageTextureContext textureContexts[]);
|
||||
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
|
||||
/** (See Skia bug 7447)
|
||||
Creates SkImage from Android hardware buffer.
|
||||
Returned SkImage takes a reference on the buffer.
|
||||
|
||||
Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
|
||||
|
||||
@param hardwareBuffer AHardwareBuffer Android hardware buffer
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeFromAHardwareBuffer(
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
SkAlphaType alphaType = kPremul_SkAlphaType,
|
||||
sk_sp<SkColorSpace> colorSpace = nullptr,
|
||||
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
||||
|
||||
/** Creates SkImage from Android hardware buffer and uploads the data from the SkPixmap to it.
|
||||
Returned SkImage takes a reference on the buffer.
|
||||
|
||||
Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
|
||||
|
||||
@param context GPU context
|
||||
@param pixmap SkPixmap that contains data to be uploaded to the AHardwareBuffer
|
||||
@param hardwareBuffer AHardwareBuffer Android hardware buffer
|
||||
@param surfaceOrigin surface origin for resulting image
|
||||
@return created SkImage, or nullptr
|
||||
*/
|
||||
static sk_sp<SkImage> MakeFromAHardwareBufferWithData(
|
||||
GrDirectContext* context,
|
||||
const SkPixmap& pixmap,
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
GrSurfaceOrigin surfaceOrigin = kTopLeft_GrSurfaceOrigin);
|
||||
#endif
|
||||
|
||||
/** Returns a SkImageInfo describing the width, height, color type, alpha type, and color space
|
||||
of the SkImage.
|
||||
|
||||
@ -717,6 +724,7 @@ public:
|
||||
*/
|
||||
bool isValid(GrRecordingContext* context) const;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/** Flushes any pending uses of texture-backed images in the GPU backend. If the image is not
|
||||
texture-backed (including promise texture images) or if the GrDirectContext does not
|
||||
have the same context ID as the context backing the image then this is a no-op.
|
||||
@ -750,6 +758,7 @@ public:
|
||||
*/
|
||||
GrBackendTexture getBackendTexture(bool flushPendingGrContextIO,
|
||||
GrSurfaceOrigin* origin = nullptr) const;
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
/** \enum SkImage::CachingHint
|
||||
CachingHint selects whether Skia may internally cache SkBitmap generated by
|
||||
@ -1062,6 +1071,7 @@ public:
|
||||
*/
|
||||
sk_sp<SkImage> withDefaultMipmaps() const;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/** Returns SkImage backed by GPU texture associated with context. Returned SkImage is
|
||||
compatible with SkSurface created with dstColorSpace. The returned SkImage respects
|
||||
mipMapped setting; if mipMapped equals GrMipmapped::kYes, the backing texture
|
||||
@ -1085,6 +1095,7 @@ public:
|
||||
sk_sp<SkImage> makeTextureImage(GrDirectContext*,
|
||||
GrMipmapped = GrMipmapped::kNo,
|
||||
SkBudgeted = SkBudgeted::kYes) const;
|
||||
#endif
|
||||
|
||||
/** Returns raster image or lazy image. Copies SkImage backed by GPU texture into
|
||||
CPU memory if needed. Returns original SkImage if decoded in raster bitmap,
|
||||
@ -1147,6 +1158,7 @@ public:
|
||||
*/
|
||||
typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc;
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
/** Creates a GrBackendTexture from the provided SkImage. Returns true and
|
||||
stores result in backendTexture and backendTextureReleaseProc if
|
||||
texture is created; otherwise, returns false and leaves
|
||||
@ -1172,7 +1184,7 @@ public:
|
||||
sk_sp<SkImage> image,
|
||||
GrBackendTexture* backendTexture,
|
||||
BackendTextureReleaseProc* backendTextureReleaseProc);
|
||||
|
||||
#endif
|
||||
/** Deprecated.
|
||||
*/
|
||||
enum LegacyBitmapMode {
|
||||
|
@ -6,13 +6,11 @@
|
||||
*/
|
||||
|
||||
#include "include/core/SkBitmap.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkImageEncoder.h"
|
||||
#include "include/core/SkImageFilter.h"
|
||||
#include "include/core/SkImageGenerator.h"
|
||||
#include "include/core/SkPicture.h"
|
||||
#include "include/core/SkString.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
#include "src/core/SkBitmapCache.h"
|
||||
#include "src/core/SkCachedData.h"
|
||||
@ -30,6 +28,8 @@
|
||||
#include "src/shaders/SkImageShader.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#include "include/gpu/GrContextThreadSafeProxy.h"
|
||||
#include "include/gpu/GrDirectContext.h"
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
@ -41,8 +41,6 @@
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/image/SkImage_Gpu.h"
|
||||
#endif
|
||||
#include "include/gpu/GrBackendSurface.h"
|
||||
#include "include/gpu/GrContextThreadSafeProxy.h"
|
||||
|
||||
SkImage::SkImage(const SkImageInfo& info, uint32_t uniqueID)
|
||||
: fInfo(info)
|
||||
@ -239,11 +237,6 @@ void SkImage::flushAndSubmit(GrDirectContext* dContext) const {
|
||||
|
||||
bool SkImage::isTextureBacked() const { return false; }
|
||||
|
||||
GrBackendTexture SkImage::getBackendTexture(bool flushPendingGrContextIO,
|
||||
GrSurfaceOrigin* origin) const {
|
||||
return GrBackendTexture(); // invalid
|
||||
}
|
||||
|
||||
bool SkImage::isValid(GrRecordingContext* rContext) const {
|
||||
if (rContext) {
|
||||
return false;
|
||||
@ -251,12 +244,6 @@ bool SkImage::isValid(GrRecordingContext* rContext) const {
|
||||
return as_IB(this)->onIsValid(nullptr);
|
||||
}
|
||||
|
||||
GrSemaphoresSubmitted SkImage::flush(GrDirectContext*, const GrFlushInfo&) const {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
void SkImage::flushAndSubmit(GrDirectContext*) const {}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -450,13 +437,13 @@ GrSurfaceProxyView SkImage_Base::FindOrMakeCachedMipmappedView(GrRecordingContex
|
||||
return copy;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
GrBackendTexture SkImage_Base::onGetBackendTexture(bool flushPendingGrContextIO,
|
||||
GrSurfaceOrigin* origin) const {
|
||||
return GrBackendTexture(); // invalid
|
||||
}
|
||||
|
||||
#endif // SK_SUPPORT_GPU
|
||||
|
||||
GrDirectContext* SkImage_Base::directContext() const {
|
||||
#if SK_SUPPORT_GPU
|
||||
return GrAsDirectContext(this->context());
|
||||
@ -672,80 +659,6 @@ sk_sp<SkImage> SkImage::makeRasterImage(CachingHint chint) const {
|
||||
return SkImage::MakeRasterData(fInfo, std::move(data), rowBytes);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !SK_SUPPORT_GPU
|
||||
|
||||
sk_sp<SkImage> SkImage::MakeFromTexture(GrRecordingContext*,
|
||||
const GrBackendTexture&, GrSurfaceOrigin,
|
||||
SkColorType, SkAlphaType, sk_sp<SkColorSpace>,
|
||||
TextureReleaseProc, ReleaseContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::MakeFromCompressedTexture(GrRecordingContext*,
|
||||
const GrBackendTexture&,
|
||||
GrSurfaceOrigin,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>,
|
||||
TextureReleaseProc,
|
||||
ReleaseContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool SkImage::MakeBackendTextureFromSkImage(GrDirectContext*,
|
||||
sk_sp<SkImage>,
|
||||
GrBackendTexture*,
|
||||
BackendTextureReleaseProc*) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::MakeFromAdoptedTexture(GrRecordingContext*,
|
||||
const GrBackendTexture&, GrSurfaceOrigin,
|
||||
SkColorType, SkAlphaType,
|
||||
sk_sp<SkColorSpace>) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::MakeFromYUVAPixmaps(GrRecordingContext* context,
|
||||
const SkYUVAPixmaps& pixmaps,
|
||||
GrMipMapped buildMips,
|
||||
bool limitToMaxTextureSize,
|
||||
sk_sp<SkColorSpace> imageColorSpace) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::makeTextureImage(GrDirectContext*, GrMipmapped, SkBudgeted) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::MakePromiseTexture(sk_sp<GrContextThreadSafeProxy>,
|
||||
const GrBackendFormat&,
|
||||
SkISize,
|
||||
GrMipmapped,
|
||||
GrSurfaceOrigin,
|
||||
SkColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>,
|
||||
PromiseImageTextureFulfillProc,
|
||||
PromiseImageTextureReleaseProc,
|
||||
PromiseImageTextureContext) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<SkImage> SkImage::MakePromiseYUVATexture(sk_sp<GrContextThreadSafeProxy>,
|
||||
const GrYUVABackendTextureInfo&,
|
||||
sk_sp<SkColorSpace>,
|
||||
PromiseImageTextureFulfillProc,
|
||||
PromiseImageTextureReleaseProc,
|
||||
PromiseImageTextureContext[]) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkImage_pinAsTexture(const SkImage* image, GrRecordingContext* rContext) {
|
||||
SkASSERT(image);
|
||||
SkASSERT(rContext);
|
||||
|
@ -117,15 +117,15 @@ public:
|
||||
// If this image is the current cached image snapshot of a surface then this is called when the
|
||||
// surface is destroyed to indicate no further writes may happen to surface backing store.
|
||||
virtual void generatingSurfaceIsDeleted() {}
|
||||
|
||||
virtual GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
|
||||
GrSurfaceOrigin* origin) const;
|
||||
#endif
|
||||
|
||||
virtual bool onPinAsTexture(GrRecordingContext*) const { return false; }
|
||||
virtual void onUnpinAsTexture(GrRecordingContext*) const {}
|
||||
virtual bool isPinnedOnContext(GrRecordingContext*) const { return false; }
|
||||
|
||||
virtual GrBackendTexture onGetBackendTexture(bool flushPendingGrContextIO,
|
||||
GrSurfaceOrigin* origin) const;
|
||||
|
||||
// return a read-only copy of the pixels. We promise to not modify them,
|
||||
// but only inspect them (or encode them).
|
||||
virtual bool getROPixels(GrDirectContext*, SkBitmap*,
|
||||
|
@ -197,8 +197,12 @@ sk_sp<SkImage> SkImage_Lazy::onMakeSubset(const SkIRect& subset, GrDirectContext
|
||||
// TODO: can we do this more efficiently, by telling the generator we want to
|
||||
// "realize" a subset?
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
auto pixels = direct ? this->makeTextureImage(direct)
|
||||
: this->makeRasterImage();
|
||||
#else
|
||||
auto pixels = this->makeRasterImage();
|
||||
#endif
|
||||
return pixels ? pixels->makeSubset(subset, direct) : nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user