@@ -22,65 +22,47 @@ GrTextureAdjuster::GrTextureAdjuster(GrRecordingContext* context,
2222 , fOriginal(std::move(original))
2323 , fUniqueID(uniqueID) {}
2424
25- void GrTextureAdjuster::makeCopyKey ( const CopyParams& params, GrUniqueKey* copyKey ) {
25+ void GrTextureAdjuster::makeMipMappedKey ( GrUniqueKey* mipMappedKey ) {
2626 // Destination color space is irrelevant - we already have a texture so we're just sub-setting
2727 GrUniqueKey baseKey;
2828 GrMakeKeyFromImageID (&baseKey, fUniqueID , SkIRect::MakeSize (this ->dimensions ()));
29- MakeCopyKeyFromOrigKey (baseKey, params, copyKey );
29+ MakeMipMappedKeyFromOriginalKey (baseKey, mipMappedKey );
3030}
3131
32- void GrTextureAdjuster::didCacheCopy (const GrUniqueKey& copyKey, uint32_t contextUniqueID) {
32+ void GrTextureAdjuster::didCacheMipMappedCopy (const GrUniqueKey& mipMappedKey,
33+ uint32_t contextUniqueID) {
3334 // We don't currently have a mechanism for notifications on Images!
3435}
3536
36- GrSurfaceProxyView GrTextureAdjuster::copy (const CopyParams& copyParams, bool willBeMipped,
37- bool copyForMipsOnly) {
37+ GrSurfaceProxyView GrTextureAdjuster::makeMippedCopy () {
3838 GrProxyProvider* proxyProvider = this ->context ()->priv ().proxyProvider ();
3939
4040 GrUniqueKey key;
41- this ->makeCopyKey (copyParams, &key);
41+ this ->makeMipMappedKey ( &key);
4242 sk_sp<GrTextureProxy> cachedCopy;
4343 const GrSurfaceProxyView& originalView = this ->originalProxyView ();
4444 if (key.isValid ()) {
4545 cachedCopy = proxyProvider->findOrCreateProxyByUniqueKey (key, this ->colorType ());
46- if (cachedCopy && (!willBeMipped || GrMipMapped::kYes == cachedCopy->mipMapped ())) {
47- // TODO: Once we no longer use CopyOnGpu which can fallback to arbitrary formats and
48- // colorTypes, we can use the swizzle of the originalView.
49- GrSwizzle swizzle = cachedCopy->textureSwizzleDoNotUse ();
50- return GrSurfaceProxyView (std::move (cachedCopy), originalView.origin (), swizzle);
46+ if (cachedCopy) {
47+ return {std::move (cachedCopy), originalView.origin (), originalView.swizzle ()};
5148 }
5249 }
5350
54- GrSurfaceProxyView copyView;
55- if (copyForMipsOnly) {
56- copyView = GrCopyBaseMipMapToTextureProxy (this ->context (), originalView.proxy (),
57- originalView.origin (), this ->colorType ());
58- } else {
59- copyView = CopyOnGpu (this ->context (), this ->originalProxyViewRef (), this ->colorType (),
60- copyParams, willBeMipped);
51+ GrSurfaceProxyView copyView = GrCopyBaseMipMapToTextureProxy (
52+ this ->context (), originalView.proxy (), originalView.origin (), this ->colorType ());
53+ if (!copyView) {
54+ return {};
6155 }
62- if (copyView.proxy ()) {
63- if (key.isValid ()) {
64- SkASSERT (copyView.origin () == originalView.origin ());
65- if (cachedCopy) {
66- SkASSERT (GrMipMapped::kYes == copyView.asTextureProxy ()->mipMapped () &&
67- GrMipMapped::kNo == cachedCopy->mipMapped ());
68- // If we had a cachedProxy, that means there already is a proxy in the cache which
69- // matches the key, but it does not have mip levels and we require them. Thus we
70- // must remove the unique key from that proxy.
71- SkASSERT (cachedCopy->getUniqueKey () == key);
72- proxyProvider->removeUniqueKeyFromProxy (cachedCopy.get ());
73- }
74- proxyProvider->assignUniqueKeyToProxy (key, copyView.asTextureProxy ());
75- this ->didCacheCopy (key, proxyProvider->contextID ());
76- }
56+ if (key.isValid ()) {
57+ SkASSERT (copyView.origin () == originalView.origin ());
58+ proxyProvider->assignUniqueKeyToProxy (key, copyView.asTextureProxy ());
59+ this ->didCacheMipMappedCopy (key, proxyProvider->contextID ());
7760 }
7861 return copyView;
7962}
8063
8164GrSurfaceProxyView GrTextureAdjuster::onRefTextureProxyViewForParams (GrSamplerState params,
82- bool willBeMipped,
83- SkScalar scaleAdjust[2 ]) {
65+ bool willBeMipped) {
8466 if (this ->context ()->priv ().abandoned ()) {
8567 // The texture was abandoned.
8668 return {};
@@ -92,51 +74,32 @@ GrSurfaceProxyView GrTextureAdjuster::onRefTextureProxyViewForParams(GrSamplerSt
9274 GrSurfaceProxyView view = this ->originalProxyViewRef ();
9375 GrTextureProxy* texProxy = view.asTextureProxy ();
9476 SkASSERT (texProxy);
95- CopyParams copyParams;
96-
97- bool needsCopyForMipsOnly = false ;
98- if (!params.isRepeated () ||
99- !GrGpu::IsACopyNeededForRepeatWrapMode (this ->context ()->priv ().caps (), texProxy,
100- texProxy->dimensions (), params.filter (), ©Params,
101- scaleAdjust)) {
102- needsCopyForMipsOnly = GrGpu::IsACopyNeededForMips (this ->context ()->priv ().caps (),
103- texProxy, params.filter (),
104- ©Params);
105- if (!needsCopyForMipsOnly) {
106- return view;
107- }
77+ if (!GrGpu::IsACopyNeededForMips (this ->context ()->priv ().caps (), texProxy, params.filter ())) {
78+ return view;
10879 }
10980
110- GrSurfaceProxyView result = this ->copy (copyParams, willBeMipped, needsCopyForMipsOnly );
111- if (!result. proxy () && needsCopyForMipsOnly ) {
81+ GrSurfaceProxyView copy = this ->makeMippedCopy ( );
82+ if (!copy ) {
11283 // If we were unable to make a copy and we only needed a copy for mips, then we will return
11384 // the source texture here and require that the GPU backend is able to fall back to using
11485 // bilerp if mips are required.
11586 return view;
11687 }
117- SkASSERT (result .asTextureProxy ());
118- return result ;
88+ SkASSERT (copy .asTextureProxy ());
89+ return copy ;
11990}
12091
12192std::unique_ptr<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor (
122- const SkMatrix& origTextureMatrix ,
93+ const SkMatrix& textureMatrix ,
12394 const SkRect& constraintRect,
12495 FilterConstraint filterConstraint,
12596 bool coordsLimitedToConstraintRect,
12697 const GrSamplerState::Filter* filterOrNullForBicubic) {
127- SkMatrix textureMatrix = origTextureMatrix;
128-
129- SkScalar scaleAdjust[2 ] = { 1 .0f , 1 .0f };
130- GrSurfaceProxyView view = this ->viewForParams (filterOrNullForBicubic, scaleAdjust);
131- if (!view.proxy ()) {
98+ GrSurfaceProxyView view = this ->viewForParams (filterOrNullForBicubic);
99+ if (!view) {
132100 return nullptr ;
133101 }
134102 SkASSERT (view.asTextureProxy ());
135- // If we made a copy then we only copied the contentArea, in which case the new texture is all
136- // content.
137- if (view.proxy () != this ->originalProxyView ().proxy ()) {
138- textureMatrix.postScale (scaleAdjust[0 ], scaleAdjust[1 ]);
139- }
140103
141104 SkRect domain;
142105 DomainMode domainMode =
0 commit comments