| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright 2016 Google Inc. | 
 | 3 |  * | 
 | 4 |  * Use of this source code is governed by a BSD-style license that can be | 
 | 5 |  * found in the LICENSE file. | 
 | 6 |  */ | 
 | 7 |  | 
 | 8 | #ifndef GrTextureAdjuster_DEFINED | 
 | 9 | #define GrTextureAdjuster_DEFINED | 
 | 10 |  | 
 | 11 | #include "GrTextureProducer.h" | 
| Hal Canary | e80e618 | 2017-04-05 12:55:32 -0400 | [diff] [blame] | 12 | #include "GrTextureProxy.h" | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 13 | #include "SkTLazy.h" | 
 | 14 |  | 
 | 15 | /** | 
 | 16 |  * Base class for sources that start out as textures. Optionally allows for a content area subrect. | 
 | 17 |  * The intent is not to use content area for subrect rendering. Rather, the pixels outside the | 
 | 18 |  * content area have undefined values and shouldn't be read *regardless* of filtering mode or | 
 | 19 |  * the SkCanvas::SrcRectConstraint used for subrect draws. | 
 | 20 |  */ | 
 | 21 | class GrTextureAdjuster : public GrTextureProducer { | 
 | 22 | public: | 
| Brian Salomon | aff329b | 2017-08-11 09:40:37 -0400 | [diff] [blame] | 23 |     std::unique_ptr<GrFragmentProcessor> createFragmentProcessor( | 
 | 24 |             const SkMatrix& textureMatrix, | 
 | 25 |             const SkRect& constraintRect, | 
 | 26 |             FilterConstraint, | 
 | 27 |             bool coordsLimitedToConstraintRect, | 
| Brian Osman | 05c8f46 | 2018-10-22 17:13:36 -0400 | [diff] [blame] | 28 |             const GrSamplerState::Filter* filterOrNullForBicubic) override; | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 29 |  | 
 | 30 |     // We do not ref the texture nor the colorspace, so the caller must keep them in scope while | 
 | 31 |     // this Adjuster is alive. | 
| Greg Daniel | c77085d | 2017-11-01 16:38:48 -0400 | [diff] [blame] | 32 |     GrTextureAdjuster(GrContext*, sk_sp<GrTextureProxy>, SkAlphaType, uint32_t uniqueID, | 
 | 33 |                       SkColorSpace*); | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 34 |  | 
 | 35 | protected: | 
 | 36 |     SkAlphaType alphaType() const override { return fAlphaType; } | 
| Brian Osman | 6064e1c | 2018-10-19 14:27:54 -0400 | [diff] [blame] | 37 |     SkColorSpace* colorSpace() const override { return fColorSpace; } | 
| Brian Osman | b3f3830 | 2018-09-07 15:24:44 -0400 | [diff] [blame] | 38 |     void makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) override; | 
| Brian Salomon | 238069b | 2018-07-11 15:58:57 -0400 | [diff] [blame] | 39 |     void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override; | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 40 |  | 
| Robert Phillips | 3798c86 | 2017-03-27 11:08:16 -0400 | [diff] [blame] | 41 |     GrTextureProxy* originalProxy() const { return fOriginal.get(); } | 
 | 42 |     sk_sp<GrTextureProxy> originalProxyRef() const { return fOriginal; } | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 43 |  | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 44 | private: | 
| Brian Salomon | 2a943df | 2018-05-04 13:43:19 -0400 | [diff] [blame] | 45 |     sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&, | 
| Greg Daniel | 8e9b4c4 | 2018-07-20 10:30:48 -0400 | [diff] [blame] | 46 |                                                      bool willBeMipped, | 
| Brian Salomon | 2a943df | 2018-05-04 13:43:19 -0400 | [diff] [blame] | 47 |                                                      SkScalar scaleAdjust[2]) override; | 
 | 48 |  | 
 | 49 |     sk_sp<GrTextureProxy> refTextureProxyCopy(const CopyParams& copyParams, bool willBeMipped); | 
 | 50 |  | 
| Robert Phillips | 3798c86 | 2017-03-27 11:08:16 -0400 | [diff] [blame] | 51 |     sk_sp<GrTextureProxy> fOriginal; | 
 | 52 |     SkAlphaType           fAlphaType; | 
 | 53 |     SkColorSpace*         fColorSpace; | 
 | 54 |     uint32_t              fUniqueID; | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 55 |  | 
| Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 56 |     typedef GrTextureProducer INHERITED; | 
 | 57 | }; | 
 | 58 |  | 
 | 59 | #endif |