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 | |
Brian Osman | e8e5458 | 2016-11-28 10:06:27 -0500 | [diff] [blame] | 11 | #include "GrTextureMaker.h" |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 12 | #include "SkImage.h" |
| 13 | |
Brian Osman | bd65955 | 2018-09-11 10:03:19 -0400 | [diff] [blame] | 14 | class SkImage_Lazy; |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 15 | |
| 16 | /** This class manages the conversion of generator-backed images to GrTextures. If the caching hint |
| 17 | is kAllow the image's ID is used for the cache key. */ |
| 18 | class GrImageTextureMaker : public GrTextureMaker { |
| 19 | public: |
Brian Osman | df7e075 | 2017-04-26 16:20:28 -0400 | [diff] [blame] | 20 | GrImageTextureMaker(GrContext* context, const SkImage* client, SkImage::CachingHint chint); |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 21 | |
| 22 | protected: |
| 23 | // TODO: consider overriding this, for the case where the underlying generator might be |
| 24 | // able to efficiently produce a "stretched" texture natively (e.g. picture-backed) |
| 25 | // GrTexture* generateTextureForParams(const CopyParams&) override; |
Robert Phillips | 0c984a0 | 2017-03-16 07:51:56 -0400 | [diff] [blame] | 26 | sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped, |
Stan Iliev | ba81af2 | 2017-06-08 15:16:53 -0400 | [diff] [blame] | 27 | SkColorSpace* dstColorSpace, |
| 28 | AllowedTexGenType onlyIfFast) override; |
Robert Phillips | 0c984a0 | 2017-03-16 07:51:56 -0400 | [diff] [blame] | 29 | |
Brian Osman | b3f3830 | 2018-09-07 15:24:44 -0400 | [diff] [blame] | 30 | void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey) override; |
Mike Reed | 30301c4 | 2018-07-19 09:39:21 -0400 | [diff] [blame] | 31 | void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override {} |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 32 | |
| 33 | SkAlphaType alphaType() const override; |
Brian Osman | 61624f0 | 2016-12-09 14:51:59 -0500 | [diff] [blame] | 34 | sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) override; |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 35 | |
| 36 | private: |
Brian Osman | bd65955 | 2018-09-11 10:03:19 -0400 | [diff] [blame] | 37 | const SkImage_Lazy* fImage; |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 38 | GrUniqueKey fOriginalKey; |
| 39 | SkImage::CachingHint fCachingHint; |
| 40 | |
| 41 | typedef GrTextureMaker INHERITED; |
| 42 | }; |
| 43 | |
| 44 | #endif |