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 GrBitmapTextureMaker_DEFINED |
| 9 | #define GrBitmapTextureMaker_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkBitmap.h" |
| 12 | #include "src/gpu/GrTextureMaker.h" |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 13 | |
| 14 | /** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is |
| 15 | non-volatile the texture is cached using a key created from the pixels' image id and the |
| 16 | subset of the pixelref specified by the bitmap. */ |
| 17 | class GrBitmapTextureMaker : public GrTextureMaker { |
| 18 | public: |
Michael Ludwig | ddeed37 | 2019-02-20 16:50:10 -0500 | [diff] [blame] | 19 | GrBitmapTextureMaker(GrRecordingContext* context, const SkBitmap& bitmap, |
| 20 | bool useDecal = false); |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 21 | |
| 22 | protected: |
Robert Phillips | 0c984a0 | 2017-03-16 07:51:56 -0400 | [diff] [blame] | 23 | sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped, |
Stan Iliev | ba81af2 | 2017-06-08 15:16:53 -0400 | [diff] [blame] | 24 | AllowedTexGenType onlyIfFast) override; |
Robert Phillips | 0c984a0 | 2017-03-16 07:51:56 -0400 | [diff] [blame] | 25 | |
Brian Osman | b3f3830 | 2018-09-07 15:24:44 -0400 | [diff] [blame] | 26 | void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) override; |
Brian Salomon | 238069b | 2018-07-11 15:58:57 -0400 | [diff] [blame] | 27 | void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override; |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 28 | |
| 29 | SkAlphaType alphaType() const override; |
Brian Osman | 6064e1c | 2018-10-19 14:27:54 -0400 | [diff] [blame] | 30 | SkColorSpace* colorSpace() const override; |
Brian Osman | 3b66ab6 | 2016-11-28 09:26:31 -0500 | [diff] [blame] | 31 | |
| 32 | private: |
| 33 | const SkBitmap fBitmap; |
| 34 | GrUniqueKey fOriginalKey; |
| 35 | |
| 36 | typedef GrTextureMaker INHERITED; |
| 37 | }; |
| 38 | |
| 39 | #endif |