blob: 0602e5accd5cb04fb6e5f95bc2ced0808f5d4aea [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 Salomon2bbdcc42017-09-07 12:36:34 -040012#include "SkBitmap.h"
Brian Osman3b66ab62016-11-28 09:26:31 -050013
14/** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is
15 non-volatile the texture is cached using a key created from the pixels' image id and the
16 subset of the pixelref specified by the bitmap. */
17class GrBitmapTextureMaker : public GrTextureMaker {
18public:
19 GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap);
20
21protected:
Robert Phillips0c984a02017-03-16 07:51:56 -040022 sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped,
Stan Ilievba81af22017-06-08 15:16:53 -040023 AllowedTexGenType onlyIfFast) override;
Robert Phillips0c984a02017-03-16 07:51:56 -040024
Brian Osmanb3f38302018-09-07 15:24:44 -040025 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) override;
Brian Salomon238069b2018-07-11 15:58:57 -040026 void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override;
Brian Osman3b66ab62016-11-28 09:26:31 -050027
28 SkAlphaType alphaType() const override;
Brian Osman6064e1c2018-10-19 14:27:54 -040029 SkColorSpace* colorSpace() const override;
Brian Osman3b66ab62016-11-28 09:26:31 -050030
31private:
32 const SkBitmap fBitmap;
33 GrUniqueKey fOriginalKey;
34
35 typedef GrTextureMaker INHERITED;
36};
37
38#endif