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 "GrTextureMaker.h" 12 #include "SkBitmap.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 GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap); 20 21 protected: 22 sk_sp<GrTextureProxy> refOriginalTextureProxy(bool willBeMipped, 23 SkColorSpace* dstColorSpace, 24 AllowedTexGenType onlyIfFast) override; 25 26 void makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey, 27 SkColorSpace* dstColorSpace) override; 28 29 void didCacheCopy(const GrUniqueKey& copyKey) override; 30 31 SkAlphaType alphaType() const override; 32 sk_sp<SkColorSpace> getColorSpace(SkColorSpace* dstColorSpace) override; 33 34 private: 35 const SkBitmap fBitmap; 36 GrUniqueKey fOriginalKey; 37 38 typedef GrTextureMaker INHERITED; 39 }; 40 41 #endif 42