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
11#include "include/core/SkImage.h"
12#include "src/gpu/GrTextureMaker.h"
13#include "src/gpu/SkGr.h"
14
15class SkImage_Lazy;
16class SkImage_GpuYUVA;
17
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. */
20class GrImageTextureMaker final : public GrTextureMaker {
21public:
22 GrImageTextureMaker(GrRecordingContext*, const SkImage* client, GrImageTexGenPolicy);
23
24private:
25 GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
26
27 const SkImage_Lazy* fImage;
28 GrImageTexGenPolicy fTexGenPolicy;
29
30 typedef GrTextureMaker INHERITED;
31};
32
33/** This class manages the conversion of generator-backed YUVA images to GrTextures. */
34class GrYUVAImageTextureMaker final : public GrTextureMaker {
35public:
36 GrYUVAImageTextureMaker(GrContext* context, const SkImage* client);
37
38 std::unique_ptr<GrFragmentProcessor> createFragmentProcessor(
39 const SkMatrix& textureMatrix,
40 const SkRect& constraintRect,
41 FilterConstraint filterConstraint,
42 bool coordsLimitedToConstraintRect,
43 GrSamplerState::WrapMode wrapX,
44 GrSamplerState::WrapMode wrapY,
45 const GrSamplerState::Filter* filterOrNullForBicubic) override;
46
47 bool isPlanar() const override { return true; }
48
49private:
50 GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override;
51
52 const SkImage_GpuYUVA* fImage;
53
54 typedef GrTextureMaker INHERITED;
55};
56
57#endif
58