Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Unified Diff: src/utils/SkLua.cpp

Issue 642353005: add drawImageRect to lua, update sample (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleLua.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkLua.cpp
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index 9880fe44085a8ecafee333ff5bed66385312d28c..1336404d8c58d3542d4af4b22a4e357bdaed7a0f 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -460,6 +460,30 @@ static int lcanvas_drawImage(lua_State* L) {
return 0;
}
+static int lcanvas_drawImageRect(lua_State* L) {
+ SkCanvas* canvas = get_ref<SkCanvas>(L, 1);
+ SkImage* image = get_ref<SkImage>(L, 2);
+ if (NULL == image) {
+ return 0;
+ }
+
+ SkRect srcR, dstR;
+ SkRect* srcRPtr = NULL;
+ if (!lua_isnil(L, 3)) {
+ srcRPtr = lua2rect(L, 3, &srcR);
+ }
+ lua2rect(L, 4, &dstR);
+
+ SkPaint paint;
+ const SkPaint* paintPtr = NULL;
+ if (lua_isnumber(L, 5)) {
+ paint.setAlpha(SkScalarRoundToInt(lua2scalar(L, 5) * 255));
+ paintPtr = &paint;
+ }
+ canvas->drawImageRect(image, srcRPtr, dstR, paintPtr);
+ return 0;
+}
+
static int lcanvas_drawPath(lua_State* L) {
get_ref<SkCanvas>(L, 1)->drawPath(*get_obj<SkPath>(L, 2),
*get_obj<SkPaint>(L, 3));
@@ -576,6 +600,7 @@ const struct luaL_Reg gSkCanvas_Methods[] = {
{ "drawOval", lcanvas_drawOval },
{ "drawCircle", lcanvas_drawCircle },
{ "drawImage", lcanvas_drawImage },
+ { "drawImageRect", lcanvas_drawImageRect },
{ "drawPath", lcanvas_drawPath },
{ "drawText", lcanvas_drawText },
{ "getSaveCount", lcanvas_getSaveCount },
« no previous file with comments | « samplecode/SampleLua.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698