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

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

Issue 1974783002: Revert of Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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
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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 get_obj<SkPaint>(L, 1)->setTextSize(lua2scalar(L, 2)); 918 get_obj<SkPaint>(L, 1)->setTextSize(lua2scalar(L, 2));
919 return 0; 919 return 0;
920 } 920 }
921 921
922 static int lpaint_getTypeface(lua_State* L) { 922 static int lpaint_getTypeface(lua_State* L) {
923 push_ref(L, get_obj<SkPaint>(L, 1)->getTypeface()); 923 push_ref(L, get_obj<SkPaint>(L, 1)->getTypeface());
924 return 1; 924 return 1;
925 } 925 }
926 926
927 static int lpaint_setTypeface(lua_State* L) { 927 static int lpaint_setTypeface(lua_State* L) {
928 get_obj<SkPaint>(L, 1)->setTypeface(sk_ref_sp(get_ref<SkTypeface>(L, 2))); 928 get_obj<SkPaint>(L, 1)->setTypeface(get_ref<SkTypeface>(L, 2));
929 return 0; 929 return 0;
930 } 930 }
931 931
932 static int lpaint_getHinting(lua_State* L) { 932 static int lpaint_getHinting(lua_State* L) {
933 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getHinting()); 933 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getHinting());
934 return 1; 934 return 1;
935 } 935 }
936 936
937 static int lpaint_getFilterQuality(lua_State* L) { 937 static int lpaint_getFilterQuality(lua_State* L) {
938 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getFilterQuality()); 938 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getFilterQuality());
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 int style = SkTypeface::kNormal; 2042 int style = SkTypeface::kNormal;
2043 2043
2044 int count = lua_gettop(L); 2044 int count = lua_gettop(L);
2045 if (count > 0 && lua_isstring(L, 1)) { 2045 if (count > 0 && lua_isstring(L, 1)) {
2046 name = lua_tolstring(L, 1, nullptr); 2046 name = lua_tolstring(L, 1, nullptr);
2047 if (count > 1 && lua_isnumber(L, 2)) { 2047 if (count > 1 && lua_isnumber(L, 2)) {
2048 style = lua_tointegerx(L, 2, nullptr) & SkTypeface::kBoldItalic; 2048 style = lua_tointegerx(L, 2, nullptr) & SkTypeface::kBoldItalic;
2049 } 2049 }
2050 } 2050 }
2051 2051
2052 sk_sp<SkTypeface> face(SkTypeface::MakeFromName(name, (SkTypeface::Style)sty le)); 2052 SkTypeface* face = SkTypeface::CreateFromName(name,
2053 (SkTypeface::Style)style);
2053 // SkDebugf("---- name <%s> style=%d, face=%p ref=%d\n", name, style, face, f ace->getRefCnt()); 2054 // SkDebugf("---- name <%s> style=%d, face=%p ref=%d\n", name, style, face, f ace->getRefCnt());
2054 if (nullptr == face) { 2055 if (nullptr == face) {
2055 face = SkTypeface::MakeDefault(); 2056 face = SkTypeface::RefDefault();
2056 } 2057 }
2057 push_ref(L, std::move(face)); 2058 push_ref(L, face)->unref();
2058 return 1; 2059 return 1;
2059 } 2060 }
2060 2061
2061 static int lsk_newRasterSurface(lua_State* L) { 2062 static int lsk_newRasterSurface(lua_State* L) {
2062 int width = lua2int_def(L, 1, 0); 2063 int width = lua2int_def(L, 1, 0);
2063 int height = lua2int_def(L, 2, 0); 2064 int height = lua2int_def(L, 2, 0);
2064 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 2065 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
2065 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); 2066 SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
2066 auto surface = SkSurface::MakeRaster(info, &props); 2067 auto surface = SkSurface::MakeRaster(info, &props);
2067 if (nullptr == surface) { 2068 if (nullptr == surface) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 REG_CLASS(L, SkTextBlob); 2137 REG_CLASS(L, SkTextBlob);
2137 REG_CLASS(L, SkTypeface); 2138 REG_CLASS(L, SkTypeface);
2138 REG_CLASS(L, SkXfermode); 2139 REG_CLASS(L, SkXfermode);
2139 } 2140 }
2140 2141
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 extern "C" int luaopen_skia(lua_State* L) {
2143 SkLua::Load(L); 2144 SkLua::Load(L);
2144 return 0; 2145 return 0;
2145 } 2146 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698