| 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 | #include "src/gpu/SkGr.h" |
| 14 | |
| 15 | /** This class manages the conversion of SW-backed bitmaps to GrTextures. If the input bitmap is |
| 16 | non-volatile the texture is cached using a key created from the pixels' image id and the |
| 17 | subset of the pixelref specified by the bitmap. */ |
| 18 | class GrBitmapTextureMaker final : public GrTextureMaker { |
| 19 | public: |
| 20 | GrBitmapTextureMaker(GrRecordingContext*, const SkBitmap&, GrImageTexGenPolicy); |
| 21 | |
| 22 | // Always uncached-budgeted. It doesn't make sense to have kApprox cached textures. Moreover,we |
| 23 | // create kApprox textures intermediate buffers and those ought to be budgeted. |
| 24 | GrBitmapTextureMaker(GrRecordingContext*, const SkBitmap&, SkBackingFit); |
| 25 | |
| 26 | private: |
| 27 | GrBitmapTextureMaker(GrRecordingContext*, const SkBitmap&, GrImageTexGenPolicy, SkBackingFit); |
| 28 | |
| 29 | GrSurfaceProxyView refOriginalTextureProxyView(GrMipMapped) override; |
| 30 | |
| 31 | const SkBitmap fBitmap; |
| 32 | const SkBackingFit fFit; |
| 33 | const SkBudgeted fBudgeted; |
| 34 | GrUniqueKey fKey; |
| 35 | |
| 36 | typedef GrTextureMaker INHERITED; |
| 37 | }; |
| 38 | |
| 39 | #endif |
| 40 |