Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2006 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef SkBitmapProcShader_DEFINED |
michael@0 | 11 | #define SkBitmapProcShader_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkShader.h" |
michael@0 | 14 | #include "SkBitmapProcState.h" |
michael@0 | 15 | #include "SkSmallAllocator.h" |
michael@0 | 16 | |
michael@0 | 17 | class SkBitmapProcShader : public SkShader { |
michael@0 | 18 | public: |
michael@0 | 19 | SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty); |
michael@0 | 20 | |
michael@0 | 21 | // overrides from SkShader |
michael@0 | 22 | virtual bool isOpaque() const SK_OVERRIDE; |
michael@0 | 23 | virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&) SK_OVERRIDE; |
michael@0 | 24 | virtual void endContext() SK_OVERRIDE; |
michael@0 | 25 | virtual uint32_t getFlags() SK_OVERRIDE { return fFlags; } |
michael@0 | 26 | virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE; |
michael@0 | 27 | virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; |
michael@0 | 28 | virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE; |
michael@0 | 29 | virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE; |
michael@0 | 30 | |
michael@0 | 31 | static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); |
michael@0 | 32 | |
michael@0 | 33 | SK_TO_STRING_OVERRIDE() |
michael@0 | 34 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) |
michael@0 | 35 | |
michael@0 | 36 | #if SK_SUPPORT_GPU |
michael@0 | 37 | GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; |
michael@0 | 38 | #endif |
michael@0 | 39 | |
michael@0 | 40 | protected: |
michael@0 | 41 | SkBitmapProcShader(SkReadBuffer& ); |
michael@0 | 42 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
michael@0 | 43 | |
michael@0 | 44 | SkBitmap fRawBitmap; // experimental for RLE encoding |
michael@0 | 45 | SkBitmapProcState fState; |
michael@0 | 46 | uint32_t fFlags; |
michael@0 | 47 | |
michael@0 | 48 | private: |
michael@0 | 49 | typedef SkShader INHERITED; |
michael@0 | 50 | }; |
michael@0 | 51 | |
michael@0 | 52 | // Commonly used allocator. It currently is only used to allocate up to 2 objects. The total |
michael@0 | 53 | // bytes requested is calculated using one of our large shaders plus the size of an Sk3DBlitter |
michael@0 | 54 | // in SkDraw.cpp |
michael@0 | 55 | typedef SkSmallAllocator<2, sizeof(SkBitmapProcShader) + sizeof(void*) * 2> SkTBlitterAllocator; |
michael@0 | 56 | |
michael@0 | 57 | // If alloc is non-NULL, it will be used to allocate the returned SkShader, and MUST outlive |
michael@0 | 58 | // the SkShader. |
michael@0 | 59 | SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::TileMode, |
michael@0 | 60 | SkTBlitterAllocator* alloc); |
michael@0 | 61 | |
michael@0 | 62 | #endif |