1 /* 2 * Copyright 2015 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 SkImageShader_DEFINED 9 #define SkImageShader_DEFINED 10 11 #include "SkImage.h" 12 #include "SkShader.h" 13 #include "SkBitmapProcShader.h" 14 15 class SkImageShader : public SkShader { 16 public: 17 static sk_sp<SkShader> Make(sk_sp<SkImage>, TileMode tx, TileMode ty, 18 const SkMatrix* localMatrix); 19 20 bool isOpaque() const override; 21 22 SK_TO_STRING_OVERRIDE() 23 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageShader) 24 25 #if SK_SUPPORT_GPU 26 sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override; 27 #endif 28 29 SkImageShader(sk_sp<SkImage>, TileMode tx, TileMode ty, const SkMatrix* localMatrix); 30 31 protected: 32 void flatten(SkWriteBuffer&) const override; 33 Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override; 34 #ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP 35 bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode*) const override; 36 #endif 37 SkImage* onIsAImage(SkMatrix*, TileMode*) const override; 38 39 bool onAppendStages(SkRasterPipeline*, SkColorSpace*, SkArenaAlloc*, 40 const SkMatrix& ctm, const SkPaint&, const SkMatrix*) const override; 41 42 sk_sp<SkImage> fImage; 43 const TileMode fTileModeX; 44 const TileMode fTileModeY; 45 46 private: 47 friend class SkShader; 48 49 typedef SkShader INHERITED; 50 }; 51 52 #endif 53