зеркало из https://github.com/mozilla/shumway.git
Render text (as shapes for now)
This commit is contained in:
Родитель
2769231266
Коммит
0361670dd7
|
@ -16,6 +16,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var StaticTextCache = { };
|
||||||
|
|
||||||
var StaticTextDefinition = (function () {
|
var StaticTextDefinition = (function () {
|
||||||
var def = {
|
var def = {
|
||||||
__class__: 'flash.text.StaticText',
|
__class__: 'flash.text.StaticText',
|
||||||
|
@ -24,6 +26,35 @@ var StaticTextDefinition = (function () {
|
||||||
var s = this.symbol;
|
var s = this.symbol;
|
||||||
if (s) {
|
if (s) {
|
||||||
this.draw = s.draw;
|
this.draw = s.draw;
|
||||||
|
|
||||||
|
var renderable = StaticTextCache[s.symbolId];
|
||||||
|
|
||||||
|
var bounds = this.getBounds(null);
|
||||||
|
var rect = new Shumway.Geometry.Rectangle(bounds.xMin / 20,
|
||||||
|
bounds.yMin / 20,
|
||||||
|
(bounds.xMax - bounds.xMin) / 20,
|
||||||
|
(bounds.yMax - bounds.yMin) / 20);
|
||||||
|
|
||||||
|
if (!renderable) {
|
||||||
|
renderable = {
|
||||||
|
source: this,
|
||||||
|
getBounds: function () {
|
||||||
|
return rect;
|
||||||
|
},
|
||||||
|
properties: { },
|
||||||
|
render: function (ctx) {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(-rect.x, -rect.y);
|
||||||
|
this.source.draw(ctx, 0, new RenderingColorTransform());
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
StaticTextCache[s.symbolId] = renderable;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._layer = new Shumway.Layers.Shape(renderable);
|
||||||
|
this._layer.origin = new Shumway.Geometry.Point(rect.x, rect.y);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
/*global avm1lib, rgbaObjToStr, rgbIntAlphaToStr, warning, FontDefinition,
|
/*global avm1lib, rgbaObjToStr, rgbIntAlphaToStr, warning, FontDefinition,
|
||||||
Errors, throwError */
|
Errors, throwError */
|
||||||
|
|
||||||
|
var TextFieldCache = { };
|
||||||
|
|
||||||
var TextFieldDefinition = (function () {
|
var TextFieldDefinition = (function () {
|
||||||
|
|
||||||
var htmlParser = document.createElement('p');
|
var htmlParser = document.createElement('p');
|
||||||
|
@ -581,6 +583,35 @@ var TextFieldDefinition = (function () {
|
||||||
} else {
|
} else {
|
||||||
this.text = '';
|
this.text = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var renderable = TextFieldCache[s.symbolId];
|
||||||
|
|
||||||
|
var bounds = this.getBounds(null);
|
||||||
|
var rect = new Shumway.Geometry.Rectangle(bounds.xMin / 20,
|
||||||
|
bounds.yMin / 20,
|
||||||
|
(bounds.xMax - bounds.xMin) / 20,
|
||||||
|
(bounds.yMax - bounds.yMin) / 20);
|
||||||
|
|
||||||
|
if (!renderable) {
|
||||||
|
renderable = {
|
||||||
|
source: this,
|
||||||
|
getBounds: function () {
|
||||||
|
return rect;
|
||||||
|
},
|
||||||
|
properties: { },
|
||||||
|
render: function (ctx) {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(-rect.x, -rect.y);
|
||||||
|
this.source.draw(ctx, 0, new RenderingColorTransform());
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TextFieldCache[s.symbolId] = renderable;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._layer = new Shumway.Layers.Shape(renderable);
|
||||||
|
this._layer.origin = new Shumway.Geometry.Point(rect.x, rect.y);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getAS2Object: function () {
|
_getAS2Object: function () {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче