blob: 380ebefbc9974e8d5e442a71c93ac99960a04d7c [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 Osman3b66ab62016-11-28 09:26:31 -050013
Brian Osmanbd659552018-09-11 10:03:19 -040014class SkImage_Lazy;
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040015class SkImage_GpuYUVA;
Brian Osman3b66ab62016-11-28 09:26:31 -050016
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 Salomonb62cee32020-02-28 13:34:16 -050019class GrImageTextureMaker final : public GrTextureMaker {
Brian Osman3b66ab62016-11-28 09:26:31 -050020public:
Robert Phillips9338c602019-02-19 12:52:29 -050021 GrImageTextureMaker(GrRecordingContext* context, const SkImage* client,
Brian Salomon777e1462020-02-28 21:10:31 -050022 SkImage::CachingHint chint);
Brian Osman3b66ab62016-11-28 09:26:31 -050023
Greg Daniel82c6b102020-01-21 10:33:22 -050024private:
Brian Salomonecbb0fb2020-02-28 18:07:32 -050025 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 Osman3b66ab62016-11-28 09:26:31 -050028 SkImage::CachingHint fCachingHint;
29
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 Salomon777e1462020-02-28 21:10:31 -050036 GrYUVAImageTextureMaker(GrContext* context, const SkImage* client);
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040037
Brian Salomonb62cee32020-02-28 13:34:16 -050038 std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
39 const SkMatrix& textureMatrix,
40 const SkRect& constraintRect,
41 FilterConstraint filterConstraint,
42 bool coordsLimitedToConstraintRect,
Brian Salomon777e1462020-02-28 21:10:31 -050043 GrSamplerState::WrapMode wrapX,
44 GrSamplerState::WrapMode wrapY,
Brian Salomonb62cee32020-02-28 13:34:16 -050045 const GrSamplerState::Filter* filterOrNullForBicubic) override;
46
Brian Salomon777e1462020-02-28 21:10:31 -050047 bool isPlanar() const override { return true; }
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040048
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040049private:
Brian Salomonecbb0fb2020-02-28 18:07:32 -050050 GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
Brian Salomonb62cee32020-02-28 13:34:16 -050051
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040052 const SkImage_GpuYUVA* fImage;
Jim Van Verth30e0d7f2018-11-02 13:36:42 -040053
54 typedef GrTextureMaker INHERITED;
55};
56
Brian Osman3b66ab62016-11-28 09:26:31 -050057#endif