Pass in a SkColorType into SkImage_Gpu ctor.
This allows us to get rid of using the GrPixelConfig on proxy to create the SkColorType Bug: skia:6718 Change-Id: I1758b79152fa1e8a1796e55d19f5e8ca0b0e8b7b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/264396 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
e4720c6864
commit
1d17543133
@ -141,8 +141,8 @@ static sk_sp<SkImage> make_reference_image(GrContext* context,
|
|||||||
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
|
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(proxy->backendFormat(),
|
||||||
GrColorType::kRGBA_8888);
|
GrColorType::kRGBA_8888);
|
||||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, kOpaque_SkAlphaType,
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view),
|
||||||
std::move(view), nullptr);
|
ii.colorType(), kOpaque_SkAlphaType, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here we're converting from a matrix that is intended for UVs to a matrix that is intended
|
// Here we're converting from a matrix that is intended for UVs to a matrix that is intended
|
||||||
|
@ -289,8 +289,9 @@ protected:
|
|||||||
|
|
||||||
// No API to draw a GrTexture directly, so we cheat and create a private image subclass
|
// No API to draw a GrTexture directly, so we cheat and create a private image subclass
|
||||||
sk_sp<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()),
|
sk_sp<SkImage> texImage(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()),
|
||||||
image->uniqueID(), kPremul_SkAlphaType,
|
image->uniqueID(), std::move(view),
|
||||||
std::move(view), image->refColorSpace()));
|
image->colorType(), image->alphaType(),
|
||||||
|
image->refColorSpace()));
|
||||||
canvas->drawImage(texImage.get(), x, y);
|
canvas->drawImage(texImage.get(), x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,6 +1292,30 @@ static constexpr GrPixelConfig GrCompressionTypeToPixelConfig(SkImage::Compressi
|
|||||||
SkUNREACHABLE;
|
SkUNREACHABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In general we try to not mix CompressionType and ColorType, but currently SkImage still requires
|
||||||
|
// an SkColorType even for CompressedTypes so we need some conversion.
|
||||||
|
static constexpr SkColorType GrCompressionTypeToSkColorType(SkImage::CompressionType compression) {
|
||||||
|
switch (compression) {
|
||||||
|
case SkImage::CompressionType::kNone: return kUnknown_SkColorType;
|
||||||
|
case SkImage::CompressionType::kETC2_RGB8_UNORM: return kRGB_888x_SkColorType;
|
||||||
|
case SkImage::CompressionType::kBC1_RGB8_UNORM: return kRGB_888x_SkColorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkUNREACHABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static constexpr GrColorType GrMaskFormatToColorType(GrMaskFormat format) {
|
||||||
|
switch (format) {
|
||||||
|
case kA8_GrMaskFormat:
|
||||||
|
return GrColorType::kAlpha_8;
|
||||||
|
case kA565_GrMaskFormat:
|
||||||
|
return GrColorType::kBGR_565;
|
||||||
|
case kARGB_GrMaskFormat:
|
||||||
|
return GrColorType::kRGBA_8888;
|
||||||
|
}
|
||||||
|
SkUNREACHABLE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ref-counted object that calls a callback from its destructor.
|
* Ref-counted object that calls a callback from its destructor.
|
||||||
*/
|
*/
|
||||||
|
@ -368,7 +368,8 @@ sk_sp<SkSpecialImage> SkSpecialImage::CopyFromRaster(const SkIRect& subset,
|
|||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
static sk_sp<SkImage> wrap_proxy_in_image(GrRecordingContext* context, sk_sp<GrTextureProxy> proxy,
|
static sk_sp<SkImage> wrap_proxy_in_image(GrRecordingContext* context, sk_sp<GrTextureProxy> proxy,
|
||||||
SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) {
|
SkColorType colorType, SkAlphaType alphaType,
|
||||||
|
sk_sp<SkColorSpace> colorSpace) {
|
||||||
// CONTEXT TODO: remove this use of 'backdoor' to create an SkImage
|
// CONTEXT TODO: remove this use of 'backdoor' to create an SkImage
|
||||||
// TODO: Once SkSpecialImage stores a GrSurfaceProxyView instead of a proxy, use that to create
|
// TODO: Once SkSpecialImage stores a GrSurfaceProxyView instead of a proxy, use that to create
|
||||||
// the view here.
|
// the view here.
|
||||||
@ -376,8 +377,8 @@ static sk_sp<SkImage> wrap_proxy_in_image(GrRecordingContext* context, sk_sp<GrT
|
|||||||
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
||||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context->priv().backdoor()),
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context->priv().backdoor()),
|
||||||
kNeedNewImageUniqueID, alphaType,
|
kNeedNewImageUniqueID, std::move(view), colorType, alphaType,
|
||||||
std::move(view), std::move(colorSpace));
|
std::move(colorSpace));
|
||||||
}
|
}
|
||||||
|
|
||||||
class SkSpecialImage_Gpu : public SkSpecialImage_Base {
|
class SkSpecialImage_Gpu : public SkSpecialImage_Base {
|
||||||
@ -423,7 +424,8 @@ public:
|
|||||||
// to be tightened (if it is deferred).
|
// to be tightened (if it is deferred).
|
||||||
sk_sp<SkImage> img =
|
sk_sp<SkImage> img =
|
||||||
sk_sp<SkImage>(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()), this->uniqueID(),
|
sk_sp<SkImage>(new SkImage_Gpu(sk_ref_sp(canvas->getGrContext()), this->uniqueID(),
|
||||||
fAlphaType, std::move(view), fColorSpace));
|
std::move(view), this->colorType(), fAlphaType,
|
||||||
|
fColorSpace));
|
||||||
|
|
||||||
canvas->drawImageRect(img, this->subset(),
|
canvas->drawImageRect(img, this->subset(),
|
||||||
dst, paint, SkCanvas::kStrict_SrcRectConstraint);
|
dst, paint, SkCanvas::kStrict_SrcRectConstraint);
|
||||||
@ -504,7 +506,8 @@ public:
|
|||||||
*subset == SkIRect::MakeSize(fTextureProxy->dimensions())) {
|
*subset == SkIRect::MakeSize(fTextureProxy->dimensions())) {
|
||||||
fTextureProxy->priv().exactify(false);
|
fTextureProxy->priv().exactify(false);
|
||||||
// The existing GrTexture is already tight so reuse it in the SkImage
|
// The existing GrTexture is already tight so reuse it in the SkImage
|
||||||
return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace);
|
return wrap_proxy_in_image(fContext, fTextureProxy, this->colorType(), fAlphaType,
|
||||||
|
fColorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<GrTextureProxy> subsetProxy(
|
sk_sp<GrTextureProxy> subsetProxy(
|
||||||
@ -517,12 +520,14 @@ public:
|
|||||||
SkASSERT(subsetProxy->priv().isExact());
|
SkASSERT(subsetProxy->priv().isExact());
|
||||||
// MDB: this is acceptable (wrapping subsetProxy in an SkImage) bc Copy will
|
// MDB: this is acceptable (wrapping subsetProxy in an SkImage) bc Copy will
|
||||||
// return a kExact-backed proxy
|
// return a kExact-backed proxy
|
||||||
return wrap_proxy_in_image(fContext, std::move(subsetProxy), fAlphaType, fColorSpace);
|
return wrap_proxy_in_image(fContext, std::move(subsetProxy), this->colorType(),
|
||||||
|
fAlphaType, fColorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
fTextureProxy->priv().exactify(true);
|
fTextureProxy->priv().exactify(true);
|
||||||
|
|
||||||
return wrap_proxy_in_image(fContext, fTextureProxy, fAlphaType, fColorSpace);
|
return wrap_proxy_in_image(fContext, fTextureProxy, this->colorType(), fAlphaType,
|
||||||
|
fColorSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* colorSpace,
|
sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* colorSpace,
|
||||||
|
@ -131,9 +131,10 @@ sk_sp<SkImage> GrContextPriv::testingOnly_getFontAtlasImage(GrMaskFormat format,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkColorType colorType = GrColorTypeToSkColorType(GrMaskFormatToColorType(format));
|
||||||
SkASSERT(views[index].proxy()->priv().isExact());
|
SkASSERT(views[index].proxy()->priv().isExact());
|
||||||
sk_sp<SkImage> image(new SkImage_Gpu(sk_ref_sp(fContext), kNeedNewImageUniqueID,
|
sk_sp<SkImage> image(new SkImage_Gpu(sk_ref_sp(fContext), kNeedNewImageUniqueID,
|
||||||
kPremul_SkAlphaType, views[index], nullptr));
|
views[index], colorType, kPremul_SkAlphaType, nullptr));
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,20 +22,6 @@ GrAtlasManager::GrAtlasManager(GrProxyProvider* proxyProvider, GrStrikeCache* gl
|
|||||||
|
|
||||||
GrAtlasManager::~GrAtlasManager() = default;
|
GrAtlasManager::~GrAtlasManager() = default;
|
||||||
|
|
||||||
static GrColorType mask_format_to_gr_color_type(GrMaskFormat format) {
|
|
||||||
switch (format) {
|
|
||||||
case kA8_GrMaskFormat:
|
|
||||||
return GrColorType::kAlpha_8;
|
|
||||||
case kA565_GrMaskFormat:
|
|
||||||
return GrColorType::kBGR_565;
|
|
||||||
case kARGB_GrMaskFormat:
|
|
||||||
return GrColorType::kRGBA_8888;
|
|
||||||
default:
|
|
||||||
SkDEBUGFAIL("unsupported GrMaskFormat");
|
|
||||||
return GrColorType::kAlpha_8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GrAtlasManager::freeAll() {
|
void GrAtlasManager::freeAll() {
|
||||||
for (int i = 0; i < kMaskFormatCount; ++i) {
|
for (int i = 0; i < kMaskFormatCount; ++i) {
|
||||||
fAtlases[i] = nullptr;
|
fAtlases[i] = nullptr;
|
||||||
@ -141,7 +127,7 @@ void GrAtlasManager::dump(GrContext* context) const {
|
|||||||
#else
|
#else
|
||||||
filename.printf("fontcache_%d%d%d.png", gDumpCount, i, pageIdx);
|
filename.printf("fontcache_%d%d%d.png", gDumpCount, i, pageIdx);
|
||||||
#endif
|
#endif
|
||||||
auto ct = mask_format_to_gr_color_type(AtlasIndexToMaskFormat(i));
|
auto ct = GrMaskFormatToColorType(AtlasIndexToMaskFormat(i));
|
||||||
save_pixels(context, views[pageIdx], ct, filename.c_str());
|
save_pixels(context, views[pageIdx], ct, filename.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,7 +150,7 @@ void GrAtlasManager::setAtlasDimensionsToMinimum_ForTesting() {
|
|||||||
bool GrAtlasManager::initAtlas(GrMaskFormat format) {
|
bool GrAtlasManager::initAtlas(GrMaskFormat format) {
|
||||||
int index = MaskFormatToAtlasIndex(format);
|
int index = MaskFormatToAtlasIndex(format);
|
||||||
if (fAtlases[index] == nullptr) {
|
if (fAtlases[index] == nullptr) {
|
||||||
GrColorType grColorType = mask_format_to_gr_color_type(format);
|
GrColorType grColorType = GrMaskFormatToColorType(format);
|
||||||
SkISize atlasDimensions = fAtlasConfig.atlasDimensions(format);
|
SkISize atlasDimensions = fAtlasConfig.atlasDimensions(format);
|
||||||
SkISize plotDimensions = fAtlasConfig.plotDimensions(format);
|
SkISize plotDimensions = fAtlasConfig.plotDimensions(format);
|
||||||
|
|
||||||
|
@ -45,18 +45,10 @@
|
|||||||
#include "src/gpu/gl/GrGLTexture.h"
|
#include "src/gpu/gl/GrGLTexture.h"
|
||||||
#include "src/image/SkImage_Gpu.h"
|
#include "src/image/SkImage_Gpu.h"
|
||||||
|
|
||||||
static SkColorType proxy_color_type(GrSurfaceProxy* proxy) {
|
SkImage_Gpu::SkImage_Gpu(sk_sp<GrContext> context, uint32_t uniqueID, GrSurfaceProxyView view,
|
||||||
SkColorType colorType;
|
SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> colorSpace)
|
||||||
if (!GrPixelConfigToColorType(proxy->config(), &colorType)) {
|
|
||||||
colorType = kUnknown_SkColorType;
|
|
||||||
}
|
|
||||||
return colorType;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkImage_Gpu::SkImage_Gpu(sk_sp<GrContext> context, uint32_t uniqueID, SkAlphaType at,
|
|
||||||
GrSurfaceProxyView view, sk_sp<SkColorSpace> colorSpace)
|
|
||||||
: INHERITED(std::move(context), view.proxy()->backingStoreDimensions(), uniqueID,
|
: INHERITED(std::move(context), view.proxy()->backingStoreDimensions(), uniqueID,
|
||||||
proxy_color_type(view.proxy()), at, colorSpace)
|
ct, at, colorSpace)
|
||||||
, fView(std::move(view)) {}
|
, fView(std::move(view)) {}
|
||||||
|
|
||||||
SkImage_Gpu::~SkImage_Gpu() {}
|
SkImage_Gpu::~SkImage_Gpu() {}
|
||||||
@ -103,13 +95,14 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
||||||
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID, this->alphaType(),
|
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID,
|
||||||
renderTargetContext->readSurfaceView(), std::move(targetCS));
|
renderTargetContext->readSurfaceView(), targetCT,
|
||||||
|
this->alphaType(), std::move(targetCS));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage_Gpu::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const {
|
sk_sp<SkImage> SkImage_Gpu::onReinterpretColorSpace(sk_sp<SkColorSpace> newCS) const {
|
||||||
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID, this->alphaType(), fView,
|
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID, fView, this->colorType(),
|
||||||
std::move(newCS));
|
this->alphaType(), std::move(newCS));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -136,8 +129,8 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
|
|||||||
|
|
||||||
GrSwizzle swizzle = ctx->priv().caps()->getReadSwizzle(proxy->backendFormat(), colorType);
|
GrSwizzle swizzle = ctx->priv().caps()->getReadSwizzle(proxy->backendFormat(), colorType);
|
||||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, at, std::move(view),
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, std::move(view),
|
||||||
std::move(colorSpace));
|
GrColorTypeToSkColorType(colorType), at, std::move(colorSpace));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage::MakeFromCompressedTexture(GrContext* ctx,
|
sk_sp<SkImage> SkImage::MakeFromCompressedTexture(GrContext* ctx,
|
||||||
@ -165,8 +158,11 @@ sk_sp<SkImage> SkImage::MakeFromCompressedTexture(GrContext* ctx,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompressionType type = caps->compressionType(tex.getBackendFormat());
|
||||||
|
SkColorType ct = GrCompressionTypeToSkColorType(type);
|
||||||
|
|
||||||
GrSurfaceProxyView view(std::move(proxy), origin, GrSwizzle::RGBA());
|
GrSurfaceProxyView view(std::move(proxy), origin, GrSwizzle::RGBA());
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, at, std::move(view),
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, std::move(view), ct, at,
|
||||||
std::move(cs));
|
std::move(cs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,8 +227,10 @@ sk_sp<SkImage> SkImage::MakeFromCompressed(GrContext* context, sk_sp<SkData> dat
|
|||||||
SkASSERT(proxy->textureSwizzle() == GrSwizzle());
|
SkASSERT(proxy->textureSwizzle() == GrSwizzle());
|
||||||
GrSurfaceProxyView view(std::move(proxy));
|
GrSurfaceProxyView view(std::move(proxy));
|
||||||
|
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, kOpaque_SkAlphaType,
|
SkColorType colorType = GrCompressionTypeToSkColorType(type);
|
||||||
std::move(view), nullptr);
|
|
||||||
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view),
|
||||||
|
colorType, kOpaque_SkAlphaType, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorSpace yuvColorSpace,
|
sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorSpace yuvColorSpace,
|
||||||
@ -259,10 +257,11 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorS
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkColorType ct = GrColorTypeToSkColorType(renderTargetContext->colorInfo().colorType());
|
||||||
SkAlphaType at = GetAlphaTypeFromYUVAIndices(yuvaIndices);
|
SkAlphaType at = GetAlphaTypeFromYUVAIndices(yuvaIndices);
|
||||||
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
// MDB: this call is okay bc we know 'renderTargetContext' was exact
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, at,
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID,
|
||||||
renderTargetContext->readSurfaceView(),
|
renderTargetContext->readSurfaceView(), ct, at,
|
||||||
renderTargetContext->colorInfo().refColorSpace());
|
renderTargetContext->colorInfo().refColorSpace());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,8 +387,7 @@ sk_sp<SkImage> SkImage::MakeFromNV12TexturesCopyWithExternalBackend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static sk_sp<SkImage> create_image_from_producer(GrContext* context, GrTextureProducer* producer,
|
static sk_sp<SkImage> create_image_from_producer(GrContext* context, GrTextureProducer* producer,
|
||||||
SkAlphaType at, uint32_t id,
|
uint32_t id, GrMipMapped mipMapped) {
|
||||||
GrMipMapped mipMapped) {
|
|
||||||
// TODO: have texture producer return a GrSurfaceProxyView
|
// TODO: have texture producer return a GrSurfaceProxyView
|
||||||
sk_sp<GrTextureProxy> proxy(producer->refTextureProxy(mipMapped));
|
sk_sp<GrTextureProxy> proxy(producer->refTextureProxy(mipMapped));
|
||||||
if (!proxy) {
|
if (!proxy) {
|
||||||
@ -398,8 +396,9 @@ static sk_sp<SkImage> create_image_from_producer(GrContext* context, GrTexturePr
|
|||||||
GrSurfaceOrigin origin = proxy->origin();
|
GrSurfaceOrigin origin = proxy->origin();
|
||||||
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
const GrSwizzle& swizzle = proxy->textureSwizzle();
|
||||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), id, at, std::move(view),
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), id, std::move(view),
|
||||||
sk_ref_sp(producer->colorSpace()));
|
GrColorTypeToSkColorType(producer->colorType()),
|
||||||
|
producer->alphaType(), sk_ref_sp(producer->colorSpace()));
|
||||||
}
|
}
|
||||||
|
|
||||||
sk_sp<SkImage> SkImage::makeTextureImage(GrContext* context, GrMipMapped mipMapped) const {
|
sk_sp<SkImage> SkImage::makeTextureImage(GrContext* context, GrMipMapped mipMapped) const {
|
||||||
@ -419,20 +418,17 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext* context, GrMipMapped mipMapp
|
|||||||
}
|
}
|
||||||
GrTextureAdjuster adjuster(context, std::move(proxy), this->imageInfo().colorInfo(),
|
GrTextureAdjuster adjuster(context, std::move(proxy), this->imageInfo().colorInfo(),
|
||||||
this->uniqueID());
|
this->uniqueID());
|
||||||
return create_image_from_producer(context, &adjuster, this->alphaType(),
|
return create_image_from_producer(context, &adjuster, this->uniqueID(), mipMapped);
|
||||||
this->uniqueID(), mipMapped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->isLazyGenerated()) {
|
if (this->isLazyGenerated()) {
|
||||||
GrImageTextureMaker maker(context, this, kDisallow_CachingHint);
|
GrImageTextureMaker maker(context, this, kDisallow_CachingHint);
|
||||||
return create_image_from_producer(context, &maker, this->alphaType(),
|
return create_image_from_producer(context, &maker, this->uniqueID(), mipMapped);
|
||||||
this->uniqueID(), mipMapped);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const SkBitmap* bmp = as_IB(this)->onPeekBitmap()) {
|
if (const SkBitmap* bmp = as_IB(this)->onPeekBitmap()) {
|
||||||
GrBitmapTextureMaker maker(context, *bmp);
|
GrBitmapTextureMaker maker(context, *bmp);
|
||||||
return create_image_from_producer(context, &maker, this->alphaType(),
|
return create_image_from_producer(context, &maker, this->uniqueID(), mipMapped);
|
||||||
this->uniqueID(), mipMapped);
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -491,8 +487,8 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
|
|||||||
}
|
}
|
||||||
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType);
|
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType);
|
||||||
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
|
||||||
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, alphaType,
|
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view),
|
||||||
std::move(view), std::move(colorSpace));
|
colorType, alphaType, std::move(colorSpace));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -623,8 +619,8 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
|
|||||||
|
|
||||||
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType);
|
GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType);
|
||||||
GrSurfaceProxyView view(std::move(proxy), surfaceOrigin, swizzle);
|
GrSurfaceProxyView view(std::move(proxy), surfaceOrigin, swizzle);
|
||||||
sk_sp<SkImage> image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, at,
|
sk_sp<SkImage> image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, view,
|
||||||
view, cs);
|
colorType, at, cs);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ struct SkYUVAIndex;
|
|||||||
|
|
||||||
class SkImage_Gpu : public SkImage_GpuBase {
|
class SkImage_Gpu : public SkImage_GpuBase {
|
||||||
public:
|
public:
|
||||||
SkImage_Gpu(sk_sp<GrContext>, uint32_t uniqueID, SkAlphaType, GrSurfaceProxyView,
|
SkImage_Gpu(sk_sp<GrContext>, uint32_t uniqueID, GrSurfaceProxyView, SkColorType, SkAlphaType,
|
||||||
sk_sp<SkColorSpace>);
|
sk_sp<SkColorSpace>);
|
||||||
~SkImage_Gpu() override;
|
~SkImage_Gpu() override;
|
||||||
|
|
||||||
|
@ -159,8 +159,8 @@ sk_sp<SkImage> SkImage_GpuBase::onMakeSubset(GrRecordingContext* context,
|
|||||||
|
|
||||||
GrSurfaceProxyView view(std::move(copyProxy), currView.origin(), currView.swizzle());
|
GrSurfaceProxyView view(std::move(copyProxy), currView.origin(), currView.swizzle());
|
||||||
// MDB: this call is okay bc we know 'sContext' was kExact
|
// MDB: this call is okay bc we know 'sContext' was kExact
|
||||||
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID, this->alphaType(),
|
return sk_make_sp<SkImage_Gpu>(fContext, kNeedNewImageUniqueID, std::move(view),
|
||||||
std::move(view), this->refColorSpace());
|
this->colorType(), this->alphaType(), this->refColorSpace());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
|
bool SkImage_GpuBase::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRB,
|
||||||
|
@ -123,8 +123,8 @@ sk_sp<SkImage> SkSurface_Gpu::onNewImageSnapshot(const SkIRect* subset) {
|
|||||||
// above copy creates a kExact surfaceContext.
|
// above copy creates a kExact surfaceContext.
|
||||||
SkASSERT(srcProxy->priv().isExact());
|
SkASSERT(srcProxy->priv().isExact());
|
||||||
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->readSwizzle());
|
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->readSwizzle());
|
||||||
image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, info.alphaType(),
|
image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, std::move(view),
|
||||||
std::move(view), info.refColorSpace());
|
info.colorType(), info.alphaType(), info.refColorSpace());
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
@ -258,8 +258,8 @@ void SkSurface_Gpu::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPai
|
|||||||
const SkImageInfo info = fDevice->imageInfo();
|
const SkImageInfo info = fDevice->imageInfo();
|
||||||
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->readSwizzle());
|
GrSurfaceProxyView view(std::move(srcProxy), rtc->origin(), rtc->readSwizzle());
|
||||||
sk_sp<SkImage> image;
|
sk_sp<SkImage> image;
|
||||||
image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, info.alphaType(),
|
image = sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID, std::move(view),
|
||||||
std::move(view), info.refColorSpace());
|
info.colorType(), info.alphaType(), info.refColorSpace());
|
||||||
canvas->drawImage(image, x, y, paint);
|
canvas->drawImage(image, x, y, paint);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user