blob: 543bbda4d40d0abf3ea1aef8ce8eb74830f7f06a [file] [log] [blame]
Brian Osmane8e54582016-11-28 10:06:27 -05001/*
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 GrTextureMaker_DEFINED
9#define GrTextureMaker_DEFINED
10
11#include "GrTextureProducer.h"
12
13/**
14 * Base class for sources that start out as something other than a texture (encoded image,
15 * picture, ...).
16 */
17class GrTextureMaker : public GrTextureProducer {
18public:
Stan Ilievba81af22017-06-08 15:16:53 -040019 enum class AllowedTexGenType : bool { kCheap, kAny };
20
Brian Salomonaff329b2017-08-11 09:40:37 -040021 std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
22 const SkMatrix& textureMatrix,
23 const SkRect& constraintRect,
24 FilterConstraint filterConstraint,
25 bool coordsLimitedToConstraintRect,
Brian Osman05c8f462018-10-22 17:13:36 -040026 const GrSamplerState::Filter* filterOrNullForBicubic) override;
Brian Osmane8e54582016-11-28 10:06:27 -050027
28protected:
Michael Ludwigddeed372019-02-20 16:50:10 -050029 GrTextureMaker(GrRecordingContext* context, int width, int height, bool isAlphaOnly,
30 bool domainNeedsLocal)
31 : INHERITED(context, width, height, isAlphaOnly, domainNeedsLocal) {}
Brian Osmane8e54582016-11-28 10:06:27 -050032
33 /**
34 * Return the maker's "original" texture. It is the responsibility of the maker to handle any
35 * caching of the original if desired.
Stan Ilievba81af22017-06-08 15:16:53 -040036 * If "genType" argument equals AllowedTexGenType::kCheap and the texture is not trivial to
37 * construct then refOriginalTextureProxy should return nullptr (for example if texture is made
38 * by drawing into a render target).
Brian Osmane8e54582016-11-28 10:06:27 -050039 */
Robert Phillips0c984a02017-03-16 07:51:56 -040040 virtual sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped,
Stan Ilievba81af22017-06-08 15:16:53 -040041 AllowedTexGenType genType) = 0;
Robert Phillips0c984a02017-03-16 07:51:56 -040042
Brian Osmane8e54582016-11-28 10:06:27 -050043private:
Brian Salomon2a943df2018-05-04 13:43:19 -040044 sk_sp<GrTextureProxy> onRefTextureProxyForParams(const GrSamplerState&,
Greg Daniel8e9b4c42018-07-20 10:30:48 -040045 bool willBeMipped,
Brian Salomon2a943df2018-05-04 13:43:19 -040046 SkScalar scaleAdjust[2]) override;
47
Brian Osmane8e54582016-11-28 10:06:27 -050048 typedef GrTextureProducer INHERITED;
49};
50
51#endif