Pass GrMipMapped boolean down to GrResourceProvider::createTexture
This is the portion of: https://skia-review.googlesource.com/c/skia/+/266916/ (Update two of GrResourceProvider's createTexture entry points) I still care about. Converting the boolean to an int and passing that down is dubious at best. Change-Id: I830cc3bfad36526bfa7884e21c9f376585d27f0b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341397 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
e7f68f3644
commit
6c70661f86
@ -375,7 +375,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMippedProxyFromBitmap(const SkBitma
|
||||
}
|
||||
return LazyCallbackResult(resourceProvider->createTexture(
|
||||
desc.fDimensions, desc.fFormat, colorType, GrRenderable::kNo, 1,
|
||||
desc.fBudgeted, GrProtected::kNo, texels.get(), mipLevelCount));
|
||||
desc.fBudgeted, GrMipMapped::kYes, GrProtected::kNo, texels.get()));
|
||||
},
|
||||
format, dims, GrMipmapped::kYes, GrMipmapStatus::kValid, GrInternalSurfaceFlags::kNone,
|
||||
SkBackingFit::kExact, budgeted, GrProtected::kNo, UseAllocator::kYes);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "include/private/GrSingleOwner.h"
|
||||
#include "src/core/SkConvertPixels.h"
|
||||
#include "src/core/SkMathPriv.h"
|
||||
#include "src/core/SkMipmap.h"
|
||||
#include "src/gpu/GrAttachment.h"
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrDataUtils.h"
|
||||
@ -47,37 +48,39 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
|
||||
GrRenderable renderable,
|
||||
int renderTargetSampleCnt,
|
||||
SkBudgeted budgeted,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
const GrMipLevel texels[],
|
||||
int mipLevelCount) {
|
||||
const GrMipLevel texels[]) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
|
||||
SkASSERT(mipLevelCount > 0);
|
||||
|
||||
if (this->isAbandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GrMipmapped mipMapped = mipLevelCount > 1 ? GrMipmapped::kYes : GrMipmapped::kNo;
|
||||
int numMipLevels = 1;
|
||||
if (mipMapped == GrMipMapped::kYes) {
|
||||
numMipLevels = SkMipmap::ComputeLevelCount(dimensions.fWidth, dimensions.fHeight) + 1;
|
||||
}
|
||||
|
||||
if (!fCaps->validateSurfaceParams(dimensions, format, renderable, renderTargetSampleCnt,
|
||||
mipMapped)) {
|
||||
return nullptr;
|
||||
}
|
||||
// Current rule is that you can provide no level data, just the base, or all the levels.
|
||||
bool hasPixels = mipLevelCount && texels[0].fPixels;
|
||||
bool hasPixels = texels[0].fPixels;
|
||||
auto scratch = this->getExactScratch(dimensions, format, renderable, renderTargetSampleCnt,
|
||||
budgeted, mipMapped, isProtected);
|
||||
if (scratch) {
|
||||
if (!hasPixels) {
|
||||
return scratch;
|
||||
}
|
||||
return this->writePixels(std::move(scratch), colorType, dimensions, texels, mipLevelCount);
|
||||
return this->writePixels(std::move(scratch), colorType, dimensions, texels, numMipLevels);
|
||||
}
|
||||
SkAutoSTMalloc<14, GrMipLevel> tmpTexels;
|
||||
SkAutoSTArray<14, std::unique_ptr<char[]>> tmpDatas;
|
||||
GrColorType tempColorType = GrColorType::kUnknown;
|
||||
if (hasPixels) {
|
||||
tempColorType = this->prepareLevels(format, colorType, dimensions, texels, mipLevelCount,
|
||||
tempColorType = this->prepareLevels(format, colorType, dimensions, texels, numMipLevels,
|
||||
&tmpTexels, &tmpDatas);
|
||||
if (tempColorType == GrColorType::kUnknown) {
|
||||
return nullptr;
|
||||
@ -85,7 +88,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
|
||||
}
|
||||
return fGpu->createTexture(dimensions, format, renderable, renderTargetSampleCnt, budgeted,
|
||||
isProtected, colorType, tempColorType, tmpTexels.get(),
|
||||
mipLevelCount);
|
||||
numMipLevels);
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> GrResourceProvider::getExactScratch(SkISize dimensions,
|
||||
@ -136,7 +139,7 @@ sk_sp<GrTexture> GrResourceProvider::createTexture(SkISize dimensions,
|
||||
return this->writePixels(std::move(tex), colorType, dimensions, &mipLevel, 1);
|
||||
} else {
|
||||
return this->createTexture(dimensions, format, colorType, renderable, renderTargetSampleCnt,
|
||||
budgeted, isProtected, &mipLevel, 1);
|
||||
budgeted, GrMipMapped::kNo, isProtected, &mipLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,9 +86,9 @@ public:
|
||||
GrRenderable renderable,
|
||||
int renderTargetSampleCnt,
|
||||
SkBudgeted budgeted,
|
||||
GrMipMapped mipMapped,
|
||||
GrProtected isProtected,
|
||||
const GrMipLevel texels[],
|
||||
int mipLevelCount);
|
||||
const GrMipLevel texels[]);
|
||||
|
||||
/**
|
||||
* Create a potentially loose fit texture with the provided data. The color type must be valid
|
||||
|
@ -280,9 +280,9 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C
|
||||
GrMipLevel data;
|
||||
data.fPixels = textureData.get();
|
||||
data.fRowBytes = textureDataRowBytes;
|
||||
sk_sp<GrTexture> tex =
|
||||
resourceProvider->createTexture(kTexDims, format, colorType, renderable, 1,
|
||||
SkBudgeted::kNo, GrProtected::kNo, &data, 1);
|
||||
sk_sp<GrTexture> tex = resourceProvider->createTexture(kTexDims, format, colorType, renderable,
|
||||
1, SkBudgeted::kNo, GrMipMapped::kNo,
|
||||
GrProtected::kNo, &data);
|
||||
if (!tex) {
|
||||
return;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ static bool setup_backend_objects(GrDirectContext* context,
|
||||
|
||||
backingTexture = resourceProvider->createTexture(
|
||||
bm.dimensions(), format, GrColorType::kRGBA_8888, GrRenderable::kNo, 1,
|
||||
SkBudgeted::kNo, GrProtected::kNo, texels.get(), mipLevelCount);
|
||||
SkBudgeted::kNo, options.fMipMapping, GrProtected::kNo, texels.get());
|
||||
if (!backingTexture) {
|
||||
fputs("Failed to create backingTexture.\n", stderr);
|
||||
return false;
|
||||
@ -195,7 +195,8 @@ static bool setup_backend_objects(GrDirectContext* context,
|
||||
|
||||
sk_sp<GrTexture> tmp = resourceProvider->createTexture(
|
||||
offscreenDims, renderableFormat, GrColorType::kRGBA_8888, GrRenderable::kYes,
|
||||
options.fOffScreenSampleCount, SkBudgeted::kNo, GrProtected::kNo, &level0, 1);
|
||||
options.fOffScreenSampleCount, SkBudgeted::kNo, GrMipMapped::kNo,
|
||||
GrProtected::kNo, &level0);
|
||||
if (!tmp || !tmp->asRenderTarget()) {
|
||||
fputs("GrTexture is invalid.\n", stderr);
|
||||
return false;
|
||||
@ -227,8 +228,8 @@ static bool setup_backend_objects(GrDirectContext* context,
|
||||
|
||||
backingTextureRenderTarget = resourceProvider->createTexture(
|
||||
offscreenDims, renderableFormat, GrColorType::kRGBA_8888, GrRenderable::kYes,
|
||||
options.fOffScreenSampleCount, SkBudgeted::kNo, GrProtected::kNo, texels.get(),
|
||||
mipLevelCount);
|
||||
options.fOffScreenSampleCount, SkBudgeted::kNo, options.fOffScreenMipMapping,
|
||||
GrProtected::kNo, texels.get());
|
||||
if (!backingTextureRenderTarget || !backingTextureRenderTarget->asRenderTarget()) {
|
||||
fputs("backingTextureRenderTarget is invalid.\n", stderr);
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user