OLD | NEW |
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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkLua.h" | 10 #include "SkLua.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 this->inval(NULL); | 93 this->inval(NULL); |
94 return true; | 94 return true; |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 } | 98 } |
99 return this->INHERITED::onQuery(evt); | 99 return this->INHERITED::onQuery(evt); |
100 } | 100 } |
101 | 101 |
102 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 102 virtual void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
| 103 SkMatrix matrix; |
| 104 matrix.setRectToRect(SkRect::MakeWH(640, 480), |
| 105 SkRect::MakeWH(this->width(), this->height()), |
| 106 SkMatrix::kCenter_ScaleToFit); |
| 107 canvas->concat(matrix); |
| 108 |
103 lua_State* L = this->ensureLua(); | 109 lua_State* L = this->ensureLua(); |
104 | 110 |
105 lua_getglobal(L, gDrawName); | 111 lua_getglobal(L, gDrawName); |
106 if (!lua_isfunction(L, -1)) { | 112 if (!lua_isfunction(L, -1)) { |
107 int t = lua_type(L, -1); | 113 int t = lua_type(L, -1); |
108 SkDebugf("--- expected %s function %d, ignoring.\n", gDrawName, t); | 114 SkDebugf("--- expected %s function %d, ignoring.\n", gDrawName, t); |
109 lua_pop(L, 1); | 115 lua_pop(L, 1); |
110 } else { | 116 } else { |
111 // does it make sense to try to "cache" the lua version of this | 117 // does it make sense to try to "cache" the lua version of this |
112 // canvas between draws? | 118 // canvas between draws? |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 private: | 152 private: |
147 SkLua* fLua; | 153 SkLua* fLua; |
148 | 154 |
149 typedef SampleView INHERITED; | 155 typedef SampleView INHERITED; |
150 }; | 156 }; |
151 | 157 |
152 ////////////////////////////////////////////////////////////////////////////// | 158 ////////////////////////////////////////////////////////////////////////////// |
153 | 159 |
154 static SkView* MyFactory() { return new LuaView; } | 160 static SkView* MyFactory() { return new LuaView; } |
155 static SkViewRegister reg(MyFactory); | 161 static SkViewRegister reg(MyFactory); |
OLD | NEW |