blob: 1a72f68e1be54d6d75ed43185e6a3f3acf3ff620 [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
Brian Osmane8e54582016-11-28 10:06:27 -050011#include "GrTextureMaker.h"
Brian Osman3b66ab62016-11-28 09:26:31 -050012#include "SkImage.h"
13
14class SkImageCacherator;
15
16/** This class manages the conversion of generator-backed images to GrTextures. If the caching hint
17 is kAllow the image's ID is used for the cache key. */
18class GrImageTextureMaker : public GrTextureMaker {
19public:
Brian Osmandf7e0752017-04-26 16:20:28 -040020 GrImageTextureMaker(GrContext* context, const SkImage* client, SkImage::CachingHint chint);
Brian Osman3b66ab62016-11-28 09:26:31 -050021
22protected:
23 // TODO: consider overriding this, for the case where the underlying generator might be
24 // able to efficiently produce a "stretched" texture natively (e.g. picture-backed)
25 // GrTexture* generateTextureForParams(const CopyParams&) override;
Robert Phillips0c984a02017-03-16 07:51:56 -040026 sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped,
Stan Ilievba81af22017-06-08 15:16:53 -040027 SkColorSpace* dstColorSpace,
28 AllowedTexGenType onlyIfFast) override;
Robert Phillips0c984a02017-03-16 07:51:56 -040029
Brian Osman3b66ab62016-11-28 09:26:31 -050030 void makeCopyKey(const CopyParams& stretch, GrUniqueKey* paramsCopyKey,
Brian Osman61624f02016-12-09 14:51:59 -050031 SkColorSpace* dstColorSpace) override;
Brian Osman3b66ab62016-11-28 09:26:31 -050032 void didCacheCopy(const GrUniqueKey& copyKey) override;
33
34 SkAlphaType alphaType() const override;
Brian Osman61624f02016-12-09 14:51:59 -050035 sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) override;
Brian Osman3b66ab62016-11-28 09:26:31 -050036
37private:
38 SkImageCacherator* fCacher;
39 const SkImage* fClient;
40 GrUniqueKey fOriginalKey;
41 SkImage::CachingHint fCachingHint;
42
43 typedef GrTextureMaker INHERITED;
44};
45
46#endif