Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -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 GrImageTextureMaker_DEFINED |
| 9 | #define GrImageTextureMaker_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkImage.h" |
| 12 | #include "src/gpu/GrTextureMaker.h" |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 13 | |
Brian Osman | bd65955 | 2018-09-11 10:03:19 -0400 | [diff] [blame] | 14 | class SkImage_Lazy; |
Jim Van Verth | 30e0d7f | 2018-11-02 13:36:42 -0400 | [diff] [blame] | 15 | class SkImage_GpuYUVA; |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 16 | |
| 17 | /** This class manages the conversion of generator-backed images to GrTextures. If the caching hint |
| 18 | is kAllow the image's ID is used for the cache key. */ |
Brian Salomon | b62cee3 | 2020-02-28 13:34:16 -0500 | [diff] [blame^] | 19 | class GrImageTextureMaker final : public GrTextureMaker { |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 20 | public: |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 21 | GrImageTextureMaker(GrRecordingContext* context, const SkImage* client, |
Michael Ludwig | ddeed37 | 2019-02-20 16:50:10 -0500 | [diff] [blame] | 22 | SkImage::CachingHint chint, bool useDecal = false); |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 23 | |
Greg Daniel | 82c6b10 | 2020-01-21 10:33:22 -0500 | [diff] [blame] | 24 | private: |
Brian Salomon | 6066b75 | 2020-02-26 15:34:27 -0500 | [diff] [blame] | 25 | GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override; |
Robert Phillips | 0c984a0 | 2017-03-16 07:51:56 -0400 | [diff] [blame] | 26 | |
Brian Osman | bd65955 | 2018-09-11 10:03:19 -0400 | [diff] [blame] | 27 | const SkImage_Lazy* fImage; |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 28 | GrUniqueKey fOriginalKey; |
| 29 | SkImage::CachingHint fCachingHint; |
| 30 | |
| 31 | typedef GrTextureMaker INHERITED; |
| 32 | }; |
| 33 | |
Jim Van Verth | 30e0d7f | 2018-11-02 13:36:42 -0400 | [diff] [blame] | 34 | /** This class manages the conversion of generator-backed YUVA images to GrTextures. */ |
Brian Salomon | b62cee3 | 2020-02-28 13:34:16 -0500 | [diff] [blame^] | 35 | class GrYUVAImageTextureMaker final : public GrTextureMaker { |
Jim Van Verth | 30e0d7f | 2018-11-02 13:36:42 -0400 | [diff] [blame] | 36 | public: |
Michael Ludwig | ddeed37 | 2019-02-20 16:50:10 -0500 | [diff] [blame] | 37 | GrYUVAImageTextureMaker(GrContext* context, const SkImage* client, bool useDecal = false); |
Jim Van Verth | 30e0d7f | 2018-11-02 13:36:42 -0400 | [diff] [blame] | 38 | |
Brian Salomon | b62cee3 | 2020-02-28 13:34:16 -0500 | [diff] [blame^] | 39 | std::unique_ptr<GrFragmentProcessor> createFragmentProcessor( |
| 40 | const SkMatrix& textureMatrix, |
| 41 | const SkRect& constraintRect, |
| 42 | FilterConstraint filterConstraint, |
| 43 | bool coordsLimitedToConstraintRect, |
| 44 | const GrSamplerState::Filter* filterOrNullForBicubic) override; |
| 45 | |
Michael Ludwig | a6a8400 | 2019-04-12 15:03:02 -0400 | [diff] [blame] | 46 | // This could be made more nuanced and compare all of the texture proxy resolutions, but |
| 47 | // it's probably not worth the effort. |
| 48 | bool hasMixedResolutions() const override { return true; } |
Jim Van Verth | 30e0d7f | 2018-11-02 13:36:42 -0400 | [diff] [blame] | 49 | |
Jim Van Verth | 30e0d7f | 2018-11-02 13:36:42 -0400 | [diff] [blame] | 50 | private: |
Brian Salomon | b62cee3 | 2020-02-28 13:34:16 -0500 | [diff] [blame^] | 51 | GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped) override; |
| 52 | |
Jim Van Verth | 30e0d7f | 2018-11-02 13:36:42 -0400 | [diff] [blame] | 53 | const SkImage_GpuYUVA* fImage; |
| 54 | GrUniqueKey fOriginalKey; |
| 55 | |
| 56 | typedef GrTextureMaker INHERITED; |
| 57 | }; |
| 58 | |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 59 | #endif |