Remove GrImageTextureMaker.
Make proxy view directly in SkImage_Lazy::onAsView. Temporarily lean on GrTextureAdjuster for SkImage_Lazy::asFragmentProcessor. Bug: skia:11877 Change-Id: I2f8b35d0571ebcf9ffba945ecdf1ac51db6e3eba Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402400 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
1c847f5a82
commit
2ee0f48d3f
@ -124,8 +124,6 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/GrImageContext.cpp",
|
||||
"$_src/gpu/GrImageContextPriv.h",
|
||||
"$_src/gpu/GrImageInfo.h",
|
||||
"$_src/gpu/GrImageTextureMaker.cpp",
|
||||
"$_src/gpu/GrImageTextureMaker.h",
|
||||
"$_src/gpu/GrInnerFanTriangulator.h",
|
||||
"$_src/gpu/GrManagedResource.cpp",
|
||||
"$_src/gpu/GrManagedResource.h",
|
||||
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/gpu/GrImageTextureMaker.h"
|
||||
|
||||
#include "src/gpu/GrColorSpaceXform.h"
|
||||
#include "src/gpu/GrImageContextPriv.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrBicubicEffect.h"
|
||||
#include "src/gpu/effects/GrYUVtoRGBEffect.h"
|
||||
#include "src/image/SkImage_GpuYUVA.h"
|
||||
#include "src/image/SkImage_Lazy.h"
|
||||
|
||||
static GrImageInfo get_image_info(GrRecordingContext* context, const SkImage* client) {
|
||||
SkASSERT(client->isLazyGenerated());
|
||||
const SkImage_Lazy* lazyImage = static_cast<const SkImage_Lazy*>(client);
|
||||
|
||||
GrColorType ct = lazyImage->colorTypeOfLockTextureProxy(context->priv().caps());
|
||||
|
||||
return {ct, client->alphaType(), client->refColorSpace(), client->dimensions()};
|
||||
}
|
||||
|
||||
GrImageTextureMaker::GrImageTextureMaker(GrRecordingContext* context,
|
||||
const SkImage* client,
|
||||
GrImageTexGenPolicy texGenPolicy)
|
||||
: INHERITED(context, get_image_info(context, client))
|
||||
, fImage(static_cast<const SkImage_Lazy*>(client))
|
||||
, fTexGenPolicy(texGenPolicy) {
|
||||
SkASSERT(client->isLazyGenerated());
|
||||
}
|
||||
|
||||
GrSurfaceProxyView GrImageTextureMaker::refOriginalTextureProxyView(GrMipmapped mipMapped) {
|
||||
return fImage->lockTextureProxyView(this->context(), fTexGenPolicy, mipMapped);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrImageTextureMaker_DEFINED
|
||||
#define GrImageTextureMaker_DEFINED
|
||||
|
||||
#include "include/core/SkImage.h"
|
||||
#include "src/gpu/GrTextureMaker.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
|
||||
class SkImage_Lazy;
|
||||
class SkImage_GpuYUVA;
|
||||
|
||||
/** This class manages the conversion of generator-backed images to GrTextures. If the caching hint
|
||||
is kAllow the image's ID is used for the cache key. */
|
||||
class GrImageTextureMaker final : public GrTextureMaker {
|
||||
public:
|
||||
GrImageTextureMaker(GrRecordingContext*, const SkImage* client, GrImageTexGenPolicy);
|
||||
|
||||
private:
|
||||
GrSurfaceProxyView refOriginalTextureProxyView(GrMipmapped) override;
|
||||
|
||||
const SkImage_Lazy* fImage;
|
||||
GrImageTexGenPolicy fTexGenPolicy;
|
||||
|
||||
using INHERITED = GrTextureMaker;
|
||||
};
|
||||
|
||||
#endif
|
@ -24,16 +24,19 @@ GrTextureAdjuster::GrTextureAdjuster(GrRecordingContext* context,
|
||||
GrSurfaceProxyView GrTextureAdjuster::makeMippedCopy() {
|
||||
GrProxyProvider* proxyProvider = this->context()->priv().proxyProvider();
|
||||
|
||||
GrUniqueKey baseKey, mipMappedKey;
|
||||
GrUniqueKey mipmappedKey;
|
||||
if (fUniqueID != SK_InvalidUniqueID) {
|
||||
GrUniqueKey baseKey;
|
||||
GrMakeKeyFromImageID(&baseKey, fUniqueID, SkIRect::MakeSize(this->dimensions()));
|
||||
if (baseKey.isValid()) {
|
||||
SkASSERT(baseKey.isValid());
|
||||
static const GrUniqueKey::Domain kMipMappedDomain = GrUniqueKey::GenerateDomain();
|
||||
GrUniqueKey::Builder builder(&mipMappedKey, baseKey, kMipMappedDomain, 0);
|
||||
{ // No extra values beyond the domain are required. Must name the var to please
|
||||
// clang-tidy.
|
||||
GrUniqueKey::Builder b(&mipmappedKey, baseKey, kMipMappedDomain, 0);
|
||||
}
|
||||
sk_sp<GrTextureProxy> cachedCopy;
|
||||
if (mipMappedKey.isValid()) {
|
||||
cachedCopy = proxyProvider->findOrCreateProxyByUniqueKey(mipMappedKey);
|
||||
if (cachedCopy) {
|
||||
SkASSERT(mipmappedKey.isValid());
|
||||
if (sk_sp<GrTextureProxy> cachedCopy =
|
||||
proxyProvider->findOrCreateProxyByUniqueKey(mipmappedKey)) {
|
||||
return {std::move(cachedCopy), fOriginal.origin(), fOriginal.swizzle()};
|
||||
}
|
||||
}
|
||||
@ -42,9 +45,9 @@ GrSurfaceProxyView GrTextureAdjuster::makeMippedCopy() {
|
||||
if (!copy) {
|
||||
return {};
|
||||
}
|
||||
if (mipMappedKey.isValid()) {
|
||||
if (mipmappedKey.isValid()) {
|
||||
// TODO: If we move listeners up from SkImage_Lazy to SkImage_Base then add one here.
|
||||
proxyProvider->assignUniqueKeyToProxy(mipMappedKey, copy.asTextureProxy());
|
||||
proxyProvider->assignUniqueKeyToProxy(mipmappedKey, copy.asTextureProxy());
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "src/gpu/GrBlurUtils.h"
|
||||
#include "src/gpu/GrDirectContextPriv.h"
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrImageTextureMaker.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceProxyPriv.h"
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "src/gpu/GrBlurUtils.h"
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrColorSpaceXform.h"
|
||||
#include "src/gpu/GrImageTextureMaker.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "src/gpu/GrGpu.h"
|
||||
#include "src/gpu/GrImageContextPriv.h"
|
||||
#include "src/gpu/GrImageInfo.h"
|
||||
#include "src/gpu/GrImageTextureMaker.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSemaphore.h"
|
||||
|
@ -24,12 +24,12 @@
|
||||
#include "src/gpu/GrCaps.h"
|
||||
#include "src/gpu/GrColorSpaceXform.h"
|
||||
#include "src/gpu/GrGpuResourcePriv.h"
|
||||
#include "src/gpu/GrImageTextureMaker.h"
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/GrSamplerState.h"
|
||||
#include "src/gpu/GrSurfaceFillContext.h"
|
||||
#include "src/gpu/GrTextureAdjuster.h"
|
||||
#include "src/gpu/GrYUVATextureProxies.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrYUVtoRGBEffect.h"
|
||||
@ -251,8 +251,8 @@ std::tuple<GrSurfaceProxyView, GrColorType> SkImage_Lazy::onAsView(
|
||||
GrRecordingContext* context,
|
||||
GrMipmapped mipmapped,
|
||||
GrImageTexGenPolicy policy) const {
|
||||
GrImageTextureMaker textureMaker(context, this, policy);
|
||||
return {textureMaker.view(mipmapped), textureMaker.colorType()};
|
||||
GrColorType ct = this->colorTypeOfLockTextureProxy(context->priv().caps());
|
||||
return {this->lockTextureProxyView(context, policy, mipmapped), ct};
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> SkImage_Lazy::onAsFragmentProcessor(
|
||||
@ -262,14 +262,22 @@ std::unique_ptr<GrFragmentProcessor> SkImage_Lazy::onAsFragmentProcessor(
|
||||
const SkMatrix& m,
|
||||
const SkRect* subset,
|
||||
const SkRect* domain) const {
|
||||
// TODO: If the CPU data is extracted as planes return a FP that reconstructs the image from
|
||||
// the planes.
|
||||
auto wmx = SkTileModeToWrapMode(tileModes[0]);
|
||||
auto wmy = SkTileModeToWrapMode(tileModes[1]);
|
||||
GrImageTextureMaker maker(rContext, this, GrImageTexGenPolicy::kDraw);
|
||||
auto mm = sampling.mipmap == SkMipmapMode::kNone ? GrMipmapped::kNo : GrMipmapped::kYes;
|
||||
auto [view, ct] = this->asView(rContext, mm);
|
||||
GrColorInfo info = this->imageInfo().colorInfo();
|
||||
info = info.makeColorType(ct);
|
||||
// We pass the invalid unique ID here because our above call to asView() should have already
|
||||
// made and cached a mipmapped texture if mipmapping was called for.
|
||||
GrTextureAdjuster adjuster(rContext, std::move(view), std::move(info), SK_InvalidUniqueID);
|
||||
if (sampling.useCubic) {
|
||||
return maker.createBicubicFragmentProcessor(m, subset, domain, wmx, wmy, sampling.cubic);
|
||||
return adjuster.createBicubicFragmentProcessor(m, subset, domain, wmx, wmy, sampling.cubic);
|
||||
}
|
||||
GrSamplerState sampler(wmx, wmy, sampling.filter, sampling.mipmap);
|
||||
return maker.createFragmentProcessor(m, subset, domain, sampler);
|
||||
return adjuster.createFragmentProcessor(m, subset, domain, sampler);
|
||||
}
|
||||
|
||||
GrSurfaceProxyView SkImage_Lazy::textureProxyViewFromPlanes(GrRecordingContext* ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user