Home | History | Annotate | Download | only in core
      1 
      2 /*
      3  * Copyright 2006 The Android Open Source Project
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 
     10 #ifndef SkBitmapProcShader_DEFINED
     11 #define SkBitmapProcShader_DEFINED
     12 
     13 #include "SkShader.h"
     14 #include "SkBitmapProcState.h"
     15 
     16 class SkBitmapProcShader : public SkShader {
     17 public:
     18     SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty);
     19 
     20     // overrides from SkShader
     21     virtual bool isOpaque() const SK_OVERRIDE;
     22     virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&) SK_OVERRIDE;
     23     virtual void endContext() SK_OVERRIDE;
     24     virtual uint32_t getFlags() SK_OVERRIDE { return fFlags; }
     25     virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE;
     26     virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE;
     27     virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
     28     virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
     29 
     30     static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
     31 
     32     SK_DEVELOPER_TO_STRING()
     33     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader)
     34 
     35 #if SK_SUPPORT_GPU
     36     GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE;
     37 #endif
     38 
     39 protected:
     40     SkBitmapProcShader(SkFlattenableReadBuffer& );
     41     virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
     42 
     43     SkBitmap          fRawBitmap;   // experimental for RLE encoding
     44     SkBitmapProcState fState;
     45     uint32_t          fFlags;
     46 
     47 private:
     48     typedef SkShader INHERITED;
     49 };
     50 
     51 #endif
     52