void flush();
/**
- * Gets the size of the base or root layer in global canvas coordinates. The
- * origin of the base layer is always (0,0). The current drawable area may be
- * smaller (due to clipping or saveLayer).
+ * DEPRECATED: call imageInfo() instead.
+ * Return the width/height of the underlying device. The current drawable
+ * area may be small (due to clipping or saveLayer). For a canvas with
+ * no device, 0,0 will be returned.
*/
- SkISize getBaseLayerSize() const;
-
- /**
- * DEPRECATED: call getBaseLayerSize
- */
- SkISize getDeviceSize() const { return this->getBaseLayerSize(); }
+ SkISize getDeviceSize() const;
/**
* DEPRECATED.
friend class SkDrawIter; // needs setupDrawForLayerDevice()
friend class AutoDrawLooper;
- friend class SkLua; // needs top layer size and offset
SkBaseDevice* createLayerDevice(const SkImageInfo&);
*/
SkBaseDevice* setRootDevice(SkBaseDevice* device);
- /**
- * Gets the size/origin of the top level layer in global canvas coordinates. We don't want this
- * to be public because it exposes decisions about layer sizes that are internal to the canvas.
- */
- SkISize getTopLayerSize() const;
- SkIPoint getTopLayerOrigin() const;
// internal methods are not virtual, so they can safely be called by other
// canvas apis, without confusing subclasses (like SkPictureRecording)
*/
#include "SkLua.h"
-
-#include "GrReducedClip.h"
#include "SkCanvas.h"
+#include "SkClipStack.h"
#include "SkData.h"
#include "SkDocument.h"
#include "SkImage.h"
const SkClipStack::Element* element;
int i = 0;
while (NULL != (element = iter.next())) {
- this->pushClipStackElement(*element);
+ lua_newtable(fL);
+ SkClipStack::Element::Type type = element->getType();
+ this->pushString(element_type(type), "type");
+ switch (type) {
+ case SkClipStack::Element::kEmpty_Type:
+ break;
+ case SkClipStack::Element::kRect_Type:
+ this->pushRect(element->getRect(), "rect");
+ break;
+ case SkClipStack::Element::kRRect_Type:
+ this->pushRRect(element->getRRect(), "rrect");
+ break;
+ case SkClipStack::Element::kPath_Type:
+ this->pushPath(element->getPath(), "path");
+ break;
+ }
+ this->pushString(region_op(element->getOp()), "op");
+ this->pushBool(element->isAA(), "aa");
lua_rawseti(fL, -2, ++i);
}
CHECK_SETFIELD(key);
}
-void SkLua::pushClipStackElement(const SkClipStack::Element& element, const char* key) {
- lua_newtable(fL);
- SkClipStack::Element::Type type = element.getType();
- this->pushString(element_type(type), "type");
- switch (type) {
- case SkClipStack::Element::kEmpty_Type:
- break;
- case SkClipStack::Element::kRect_Type:
- this->pushRect(element.getRect(), "rect");
- break;
- case SkClipStack::Element::kRRect_Type:
- this->pushRRect(element.getRRect(), "rrect");
- break;
- case SkClipStack::Element::kPath_Type:
- this->pushPath(element.getPath(), "path");
- break;
- }
- this->pushString(region_op(element.getOp()), "op");
- this->pushBool(element.isAA(), "aa");
- CHECK_SETFIELD(key);
-}
-
-
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
return 1;
}
-int SkLua::lcanvas_getReducedClipStack(lua_State* L) {
- const SkCanvas* canvas = get_ref<SkCanvas>(L, 1);
- SkISize layerSize = canvas->getTopLayerSize();
- SkIPoint layerOrigin = canvas->getTopLayerOrigin();
- SkIRect queryBounds = SkIRect::MakeXYWH(layerOrigin.fX, layerOrigin.fY,
- layerSize.fWidth, layerSize.fHeight);
-
- GrReducedClip::ElementList elements;
- GrReducedClip::InitialState initialState;
- int32_t genID;
- SkIRect resultBounds;
-
- const SkClipStack& stack = *canvas->getClipStack();
-
- GrReducedClip::ReduceClipStack(stack,
- queryBounds,
- &elements,
- &genID,
- &initialState,
- &resultBounds,
- NULL);
-
- GrReducedClip::ElementList::Iter iter(elements);
- int i = 0;
- lua_newtable(L);
- while(NULL != iter.get()) {
- SkLua(L).pushClipStackElement(*iter.get());
- iter.next();
- lua_rawseti(L, -2, ++i);
- }
- // Currently this only returns the element list to lua, not the initial state or result bounds.
- // It could return these as additional items on the lua stack.
- return 1;
-}
-
static int lcanvas_save(lua_State* L) {
lua_pushinteger(L, get_ref<SkCanvas>(L, 1)->save());
return 1;
return 0;
}
-const struct luaL_Reg gSkCanvas_Methods[] = {
+static const struct luaL_Reg gSkCanvas_Methods[] = {
{ "drawColor", lcanvas_drawColor },
{ "drawRect", lcanvas_drawRect },
{ "drawOval", lcanvas_drawOval },
{ "getSaveCount", lcanvas_getSaveCount },
{ "getTotalMatrix", lcanvas_getTotalMatrix },
{ "getClipStack", lcanvas_getClipStack },
- { "getReducedClipStack", SkLua::lcanvas_getReducedClipStack },
{ "save", lcanvas_save },
{ "restore", lcanvas_restore },
{ "scale", lcanvas_scale },
function sk_scrape_accumulate(t)
if (t.verb == "restore") then
restoreCount = restoreCount + 1;
- -- io.write("Clip Stack at restore #", restoreCount, ":\n")
- io.write("Reduced Clip Stack at restore #", restoreCount, ":\n")
+ io.write("Clip Stack at restore #", restoreCount, ":\n")
for i = 1, #clipstack do
local element = clipstack[i];
io.write("\t", element["op"], ", ", element["type"], ", aa:", tostring(element["aa"]))
end
io.write("\n")
else
- -- clipstack = canvas:getClipStack()
- clipstack = canvas:getReducedClipStack()
+ clipstack = canvas:getClipStack()
end
end