blob: 419649c24a3879ea75bde257ee298bb1ae10e88a [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 GrBitmapTextureMaker_DEFINED
9#define GrBitmapTextureMaker_DEFINED
10
Brian Osmane8e54582016-11-28 10:06:27 -050011#include "GrTextureMaker.h"
Brian Osman3b66ab62016-11-28 09:26:31 -050012
13/** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is
14 non-volatile the texture is cached using a key created from the pixels' image id and the
15 subset of the pixelref specified by the bitmap. */
16class GrBitmapTextureMaker : public GrTextureMaker {
17public:
18 GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap);
19
20protected:
Robert Phillips0c984a02017-03-16 07:51:56 -040021 sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped,
Stan Ilievba81af22017-06-08 15:16:53 -040022 SkColorSpace* dstColorSpace,
23 AllowedTexGenType onlyIfFast) override;
Robert Phillips0c984a02017-03-16 07:51:56 -040024
Brian Osman3b66ab62016-11-28 09:26:31 -050025 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey,
Brian Osman61624f02016-12-09 14:51:59 -050026 SkColorSpace* dstColorSpace) override;
Brian Osman3b66ab62016-11-28 09:26:31 -050027
28 void didCacheCopy(const GrUniqueKey& copyKey) override;
29
30 SkAlphaType alphaType() const override;
Brian Osman61624f02016-12-09 14:51:59 -050031 sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) override;
Brian Osman3b66ab62016-11-28 09:26:31 -050032
33private:
34 const SkBitmap fBitmap;
35 GrUniqueKey fOriginalKey;
36
37 typedef GrTextureMaker INHERITED;
38};
39
40#endif