epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #ifndef SkBitmapProcShader_DEFINED |
| 11 | #define SkBitmapProcShader_DEFINED |
| 12 | |
| 13 | #include "SkShader.h" |
| 14 | #include "SkBitmapProcState.h" |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 15 | #include "SkSmallAllocator.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | |
| 17 | class SkBitmapProcShader : public SkShader { |
| 18 | public: |
| 19 | SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty); |
| 20 | |
| 21 | // overrides from SkShader |
junov@chromium.org | b6e1619 | 2011-12-09 15:48:03 +0000 | [diff] [blame] | 22 | virtual bool isOpaque() const SK_OVERRIDE; |
robertphillips@google.com | 76f9e93 | 2013-01-15 20:17:47 +0000 | [diff] [blame] | 23 | virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&) SK_OVERRIDE; |
| 24 | virtual void endContext() SK_OVERRIDE; |
| 25 | virtual uint32_t getFlags() SK_OVERRIDE { return fFlags; } |
| 26 | virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE; |
reed@google.com | 3bafe74 | 2012-10-12 18:56:18 +0000 | [diff] [blame] | 27 | virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; |
robertphillips@google.com | 76f9e93 | 2013-01-15 20:17:47 +0000 | [diff] [blame] | 28 | virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE; |
| 29 | virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 30 | |
| 31 | static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); |
skia.committer@gmail.com | ff21c2e | 2013-01-16 07:05:56 +0000 | [diff] [blame] | 32 | |
robertphillips@google.com | 76f9e93 | 2013-01-15 20:17:47 +0000 | [diff] [blame] | 33 | SK_DEVELOPER_TO_STRING() |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 34 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 35 | |
bsalomon@google.com | e197cbf | 2013-01-14 16:46:26 +0000 | [diff] [blame] | 36 | #if SK_SUPPORT_GPU |
bsalomon@google.com | 0ac6af4 | 2013-01-16 15:16:18 +0000 | [diff] [blame] | 37 | GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; |
bsalomon@google.com | e197cbf | 2013-01-14 16:46:26 +0000 | [diff] [blame] | 38 | #endif |
| 39 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | protected: |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 41 | SkBitmapProcShader(SkReadBuffer& ); |
| 42 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 43 | |
| 44 | SkBitmap fRawBitmap; // experimental for RLE encoding |
| 45 | SkBitmapProcState fState; |
| 46 | uint32_t fFlags; |
| 47 | |
reed@google.com | 7c2f27d | 2011-03-07 19:29:00 +0000 | [diff] [blame] | 48 | private: |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 49 | typedef SkShader INHERITED; |
| 50 | }; |
| 51 | |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 52 | // Commonly used allocator. It currently is only used to allocate up to 2 objects. The total |
| 53 | // bytes requested is calculated using one of our large shaders plus the size of an Sk3DBlitter |
| 54 | // in SkDraw.cpp |
| 55 | typedef SkSmallAllocator<2, sizeof(SkBitmapProcShader) + sizeof(void*) * 2> SkTBlitterAllocator; |
| 56 | |
| 57 | // If alloc is non-NULL, it will be used to allocate the returned SkShader, and MUST outlive |
| 58 | // the SkShader. |
| 59 | SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::TileMode, |
| 60 | SkTBlitterAllocator* alloc); |
| 61 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 62 | #endif |