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

Side by Side Diff: src/utils/SkLua.cpp

Issue 1817383002: switch surface to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/utils/SkRGBAToYUV.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLua.h" 8 #include "SkLua.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 709
710 static int lcanvas_concat(lua_State* L) { 710 static int lcanvas_concat(lua_State* L) {
711 get_ref<SkCanvas>(L, 1)->concat(*get_obj<SkMatrix>(L, 2)); 711 get_ref<SkCanvas>(L, 1)->concat(*get_obj<SkMatrix>(L, 2));
712 return 0; 712 return 0;
713 } 713 }
714 714
715 static int lcanvas_newSurface(lua_State* L) { 715 static int lcanvas_newSurface(lua_State* L) {
716 int width = lua2int_def(L, 2, 0); 716 int width = lua2int_def(L, 2, 0);
717 int height = lua2int_def(L, 3, 0); 717 int height = lua2int_def(L, 3, 0);
718 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 718 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
719 SkSurface* surface = get_ref<SkCanvas>(L, 1)->newSurface(info); 719 auto surface = get_ref<SkCanvas>(L, 1)->makeSurface(info);
720 if (nullptr == surface) { 720 if (nullptr == surface) {
721 lua_pushnil(L); 721 lua_pushnil(L);
722 } else { 722 } else {
723 push_ref(L, surface)->unref(); 723 push_ref(L, surface);
724 } 724 }
725 return 1; 725 return 1;
726 } 726 }
727 727
728 static int lcanvas_gc(lua_State* L) { 728 static int lcanvas_gc(lua_State* L) {
729 get_ref<SkCanvas>(L, 1)->unref(); 729 get_ref<SkCanvas>(L, 1)->unref();
730 return 0; 730 return 0;
731 } 731 }
732 732
733 const struct luaL_Reg gSkCanvas_Methods[] = { 733 const struct luaL_Reg gSkCanvas_Methods[] = {
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 } else { 1762 } else {
1763 push_ref(L, image); 1763 push_ref(L, image);
1764 } 1764 }
1765 return 1; 1765 return 1;
1766 } 1766 }
1767 1767
1768 static int lsurface_newSurface(lua_State* L) { 1768 static int lsurface_newSurface(lua_State* L) {
1769 int width = lua2int_def(L, 2, 0); 1769 int width = lua2int_def(L, 2, 0);
1770 int height = lua2int_def(L, 3, 0); 1770 int height = lua2int_def(L, 3, 0);
1771 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 1771 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
1772 SkSurface* surface = get_ref<SkSurface>(L, 1)->newSurface(info); 1772 auto surface = get_ref<SkSurface>(L, 1)->makeSurface(info);
1773 if (nullptr == surface) { 1773 if (nullptr == surface) {
1774 lua_pushnil(L); 1774 lua_pushnil(L);
1775 } else { 1775 } else {
1776 push_ref(L, surface)->unref(); 1776 push_ref(L, surface);
1777 } 1777 }
1778 return 1; 1778 return 1;
1779 } 1779 }
1780 1780
1781 static int lsurface_gc(lua_State* L) { 1781 static int lsurface_gc(lua_State* L) {
1782 get_ref<SkSurface>(L, 1)->unref(); 1782 get_ref<SkSurface>(L, 1)->unref();
1783 return 0; 1783 return 0;
1784 } 1784 }
1785 1785
1786 static const struct luaL_Reg gSkSurface_Methods[] = { 1786 static const struct luaL_Reg gSkSurface_Methods[] = {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 } 2056 }
2057 push_ref(L, face)->unref(); 2057 push_ref(L, face)->unref();
2058 return 1; 2058 return 1;
2059 } 2059 }
2060 2060
2061 static int lsk_newRasterSurface(lua_State* L) { 2061 static int lsk_newRasterSurface(lua_State* L) {
2062 int width = lua2int_def(L, 1, 0); 2062 int width = lua2int_def(L, 1, 0);
2063 int height = lua2int_def(L, 2, 0); 2063 int height = lua2int_def(L, 2, 0);
2064 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 2064 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
2065 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); 2065 SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
2066 SkSurface* surface = SkSurface::NewRaster(info, &props); 2066 auto surface = SkSurface::MakeRaster(info, &props);
2067 if (nullptr == surface) { 2067 if (nullptr == surface) {
2068 lua_pushnil(L); 2068 lua_pushnil(L);
2069 } else { 2069 } else {
2070 push_ref(L, surface)->unref(); 2070 push_ref(L, surface);
2071 } 2071 }
2072 return 1; 2072 return 1;
2073 } 2073 }
2074 2074
2075 static int lsk_loadImage(lua_State* L) { 2075 static int lsk_loadImage(lua_State* L) {
2076 if (lua_gettop(L) > 0 && lua_isstring(L, 1)) { 2076 if (lua_gettop(L) > 0 && lua_isstring(L, 1)) {
2077 const char* name = lua_tolstring(L, 1, nullptr); 2077 const char* name = lua_tolstring(L, 1, nullptr);
2078 sk_sp<SkData> data(SkData::MakeFromFileName(name)); 2078 sk_sp<SkData> data(SkData::MakeFromFileName(name));
2079 if (data) { 2079 if (data) {
2080 auto image = SkImage::MakeFromEncoded(std::move(data)); 2080 auto image = SkImage::MakeFromEncoded(std::move(data));
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 REG_CLASS(L, SkTextBlob); 2136 REG_CLASS(L, SkTextBlob);
2137 REG_CLASS(L, SkTypeface); 2137 REG_CLASS(L, SkTypeface);
2138 REG_CLASS(L, SkXfermode); 2138 REG_CLASS(L, SkXfermode);
2139 } 2139 }
2140 2140
2141 extern "C" int luaopen_skia(lua_State* L); 2141 extern "C" int luaopen_skia(lua_State* L);
2142 extern "C" int luaopen_skia(lua_State* L) { 2142 extern "C" int luaopen_skia(lua_State* L) {
2143 SkLua::Load(L); 2143 SkLua::Load(L);
2144 return 0; 2144 return 0;
2145 } 2145 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/utils/SkRGBAToYUV.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698