blob: 332be2e51b560757707e2763f6cd15123a3c9687 [file] [log] [blame]
Brian Osman3b66ab62016-11-28 09:26:31 -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 GrImageTextureMaker_DEFINED
9#define GrImageTextureMaker_DEFINED
10
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkImage.h"
12#include "src/gpu/GrTextureMaker.h"
Brian Salomonbc074a62020-03-18 10:06:13 -040013#include "src/gpu/SkGr.h"
Brian Osman3b66ab62016-11-28 09:26:31 -050014
Brian Osmanbd659552018-09-11 10:03:19 -040015class SkImage_Lazy;
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040016class SkImage_GpuYUVA;
Brian Osman3b66ab62016-11-28 09:26:31 -050017
18/** This class manages the conversion of generator-backed images to GrTextures. If the caching hint
19 is kAllow the image's ID is used for the cache key. */
Brian Salomonb62cee32020-02-28 13:34:16 -050020class GrImageTextureMaker final : public GrTextureMaker {
Brian Osman3b66ab62016-11-28 09:26:31 -050021public:
Brian Salomonbc074a62020-03-18 10:06:13 -040022 GrImageTextureMaker(GrRecordingContext*, const SkImage* client, GrImageTexGenPolicy);
Brian Osman3b66ab62016-11-28 09:26:31 -050023
Greg Daniel82c6b102020-01-21 10:33:22 -050024private:
Brian Salomon7e67dca2020-07-21 09:27:25 -040025 GrSurfaceProxyView refOriginalTextureProxyView(GrMipmapped) override;
Robert Phillips0c984a02017-03-16 07:51:56 -040026
Brian Osmanbd659552018-09-11 10:03:19 -040027 const SkImage_Lazy* fImage;
Brian Salomonbc074a62020-03-18 10:06:13 -040028 GrImageTexGenPolicy fTexGenPolicy;
Brian Osman3b66ab62016-11-28 09:26:31 -050029
30 typedef GrTextureMaker INHERITED;
31};
32
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040033/** This class manages the conversion of generator-backed YUVA images to GrTextures. */
Brian Salomonb62cee32020-02-28 13:34:16 -050034class GrYUVAImageTextureMaker final : public GrTextureMaker {
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040035public:
Brian Salomon0c243202020-06-29 14:29:25 -040036 GrYUVAImageTextureMaker(GrRecordingContext* context, const SkImage* client);
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040037
Brian Salomon0ea33072020-07-14 10:43:42 -040038 std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(const SkMatrix& textureMatrix,
39 const SkRect* subset,
40 const SkRect* domain,
41 GrSamplerState) override;
42
43 std::unique_ptr<GrFragmentProcessor> createBicubicFragmentProcessor(
Brian Salomonb62cee32020-02-28 13:34:16 -050044 const SkMatrix& textureMatrix,
Brian Salomon0ea33072020-07-14 10:43:42 -040045 const SkRect* subset,
46 const SkRect* domain,
Brian Salomon777e1462020-02-28 21:10:31 -050047 GrSamplerState::WrapMode wrapX,
Brian Salomon0ea33072020-07-14 10:43:42 -040048 GrSamplerState::WrapMode wrapY) override;
Brian Salomonb62cee32020-02-28 13:34:16 -050049
Brian Salomon777e1462020-02-28 21:10:31 -050050 bool isPlanar() const override { return true; }
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040051
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040052private:
Brian Salomon7e67dca2020-07-21 09:27:25 -040053 GrSurfaceProxyView refOriginalTextureProxyView(GrMipmapped) override;
Brian Salomonb62cee32020-02-28 13:34:16 -050054
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040055 const SkImage_GpuYUVA* fImage;
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040056
57 typedef GrTextureMaker INHERITED;
58};
59
Brian Osman3b66ab62016-11-28 09:26:31 -050060#endif