1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkBitmapProcShader.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkBitmapProcShader_DEFINED 1.14 +#define SkBitmapProcShader_DEFINED 1.15 + 1.16 +#include "SkShader.h" 1.17 +#include "SkBitmapProcState.h" 1.18 +#include "SkSmallAllocator.h" 1.19 + 1.20 +class SkBitmapProcShader : public SkShader { 1.21 +public: 1.22 + SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty); 1.23 + 1.24 + // overrides from SkShader 1.25 + virtual bool isOpaque() const SK_OVERRIDE; 1.26 + virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&) SK_OVERRIDE; 1.27 + virtual void endContext() SK_OVERRIDE; 1.28 + virtual uint32_t getFlags() SK_OVERRIDE { return fFlags; } 1.29 + virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE; 1.30 + virtual ShadeProc asAShadeProc(void** ctx) SK_OVERRIDE; 1.31 + virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE; 1.32 + virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE; 1.33 + 1.34 + static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty); 1.35 + 1.36 + SK_TO_STRING_OVERRIDE() 1.37 + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapProcShader) 1.38 + 1.39 +#if SK_SUPPORT_GPU 1.40 + GrEffectRef* asNewEffect(GrContext*, const SkPaint&) const SK_OVERRIDE; 1.41 +#endif 1.42 + 1.43 +protected: 1.44 + SkBitmapProcShader(SkReadBuffer& ); 1.45 + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 1.46 + 1.47 + SkBitmap fRawBitmap; // experimental for RLE encoding 1.48 + SkBitmapProcState fState; 1.49 + uint32_t fFlags; 1.50 + 1.51 +private: 1.52 + typedef SkShader INHERITED; 1.53 +}; 1.54 + 1.55 +// Commonly used allocator. It currently is only used to allocate up to 2 objects. The total 1.56 +// bytes requested is calculated using one of our large shaders plus the size of an Sk3DBlitter 1.57 +// in SkDraw.cpp 1.58 +typedef SkSmallAllocator<2, sizeof(SkBitmapProcShader) + sizeof(void*) * 2> SkTBlitterAllocator; 1.59 + 1.60 +// If alloc is non-NULL, it will be used to allocate the returned SkShader, and MUST outlive 1.61 +// the SkShader. 1.62 +SkShader* CreateBitmapShader(const SkBitmap& src, SkShader::TileMode, SkShader::TileMode, 1.63 + SkTBlitterAllocator* alloc); 1.64 + 1.65 +#endif