• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 GrBitmapTextureMaker_DEFINED
9 #define GrBitmapTextureMaker_DEFINED
10 
11 #include "include/core/SkBitmap.h"
12 #include "src/gpu/GrTextureMaker.h"
13 
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. */
17 class GrBitmapTextureMaker : public GrTextureMaker {
18 public:
19     enum class Cached { kNo, kYes };
20 
21     GrBitmapTextureMaker(GrRecordingContext* context, const SkBitmap& bitmap,
22                          Cached cached = Cached::kNo, SkBackingFit = SkBackingFit::kExact,
23                          bool useDecal = false);
24 
25 private:
26     GrSurfaceProxyView refOriginalTextureProxyView(bool willBeMipped,
27                                                    AllowedTexGenType onlyIfFast) override;
28 
29     void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey) override;
30     void didCacheCopy(const GrUniqueKey& copyKey, uint32_t contextUniqueID) override;
31 
32     const SkBitmap     fBitmap;
33     const SkBackingFit fFit;
34     GrUniqueKey        fOriginalKey;
35 
36     typedef GrTextureMaker INHERITED;
37 };
38 
39 #endif
40