SkBitmapProcShader.h revision 7c2f27d788fff9dbf66a6d52753e47f786a313c0
18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* libs/graphics/sgl/SkBitmapShader.h
28a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com**
38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** Copyright 2006, The Android Open Source Project
48a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com**
57c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com** Licensed under the Apache License, Version 2.0 (the "License");
67c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com** you may not use this file except in compliance with the License.
77c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com** You may obtain a copy of the License at
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com**
97c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com**     http://www.apache.org/licenses/LICENSE-2.0
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com**
117c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com** Unless required by applicable law or agreed to in writing, software
127c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com** distributed under the License is distributed on an "AS IS" BASIS,
137c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
147c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com** See the License for the specific language governing permissions and
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com** limitations under the License.
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkBitmapProcShader_DEFINED
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkBitmapProcShader_DEFINED
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkShader.h"
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkBitmapProcState.h"
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkBitmapProcShader : public SkShader {
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBitmapProcShader(const SkBitmap& src, TileMode tx, TileMode ty);
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // overrides from SkShader
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual bool setContext(const SkBitmap&, const SkPaint&, const SkMatrix&);
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual uint32_t getFlags() { return fFlags; }
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count);
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count);
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void beginSession();
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void endSession();
357c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com    virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*,
367c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com                                 SkScalar* twoPointRadialParams) const;
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    static bool CanDo(const SkBitmap&, TileMode tx, TileMode ty);
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
407c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.com    static SkFlattenable* CreateProc(SkFlattenableReadBuffer& buffer) {
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkNEW_ARGS(SkBitmapProcShader, (buffer));
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // override from flattenable
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual bool toDumpString(SkString* str) const;
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprotected:
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBitmapProcShader(SkFlattenableReadBuffer& );
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual void flatten(SkFlattenableWriteBuffer& );
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    virtual Factory getFactory() { return CreateProc; }
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBitmap          fRawBitmap;   // experimental for RLE encoding
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkBitmapProcState fState;
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint32_t          fFlags;
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
567c2f27d788fff9dbf66a6d52753e47f786a313c0reed@google.comprivate:
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    typedef SkShader INHERITED;
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
61