gfx/skia/trunk/include/utils/SkLua.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/utils/SkLua.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/*
     1.5 + * Copyright 2013 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#ifndef SkLua_DEFINED
    1.12 +#define SkLua_DEFINED
    1.13 +
    1.14 +#include "SkClipStack.h"
    1.15 +#include "SkColor.h"
    1.16 +#include "SkScalar.h"
    1.17 +#include "SkString.h"
    1.18 +
    1.19 +struct lua_State;
    1.20 +
    1.21 +class SkCanvas;
    1.22 +class SkMatrix;
    1.23 +class SkPaint;
    1.24 +class SkPath;
    1.25 +struct SkRect;
    1.26 +class SkRRect;
    1.27 +
    1.28 +#define SkScalarToLua(x)    SkScalarToDouble(x)
    1.29 +#define SkLuaToScalar(x)    SkDoubleToScalar(x)
    1.30 +
    1.31 +class SkLua {
    1.32 +public:
    1.33 +    static void Load(lua_State*);
    1.34 +
    1.35 +    SkLua(const char termCode[] = NULL);    // creates a new L, will close it
    1.36 +    SkLua(lua_State*);                      // uses L, will not close it
    1.37 +    ~SkLua();
    1.38 +
    1.39 +    lua_State* get() const { return fL; }
    1.40 +    lua_State* operator*() const { return fL; }
    1.41 +    lua_State* operator->() const { return fL; }
    1.42 +
    1.43 +    bool runCode(const char code[]);
    1.44 +    bool runCode(const void* code, size_t size);
    1.45 +
    1.46 +    void pushBool(bool, const char tableKey[] = NULL);
    1.47 +    void pushString(const char[], const char tableKey[] = NULL);
    1.48 +    void pushString(const char[], size_t len, const char tableKey[] = NULL);
    1.49 +    void pushString(const SkString&, const char tableKey[] = NULL);
    1.50 +    void pushArrayU16(const uint16_t[], int count, const char tableKey[] = NULL);
    1.51 +    void pushColor(SkColor, const char tableKey[] = NULL);
    1.52 +    void pushU32(uint32_t, const char tableKey[] = NULL);
    1.53 +    void pushScalar(SkScalar, const char tableKey[] = NULL);
    1.54 +    void pushRect(const SkRect&, const char tableKey[] = NULL);
    1.55 +    void pushRRect(const SkRRect&, const char tableKey[] = NULL);
    1.56 +    void pushMatrix(const SkMatrix&, const char tableKey[] = NULL);
    1.57 +    void pushPaint(const SkPaint&, const char tableKey[] = NULL);
    1.58 +    void pushPath(const SkPath&, const char tableKey[] = NULL);
    1.59 +    void pushCanvas(SkCanvas*, const char tableKey[] = NULL);
    1.60 +    void pushClipStack(const SkClipStack&, const char tableKey[] = NULL);
    1.61 +    void pushClipStackElement(const SkClipStack::Element& element, const char tableKey[] = NULL);
    1.62 +
    1.63 +    // This SkCanvas lua methods is declared here to benefit from SkLua's friendship with SkCanvas.
    1.64 +    static int lcanvas_getReducedClipStack(lua_State* L);
    1.65 +
    1.66 +private:
    1.67 +    lua_State*  fL;
    1.68 +    SkString    fTermCode;
    1.69 +    bool        fWeOwnL;
    1.70 +};
    1.71 +
    1.72 +#endif

mercurial