1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */
8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkDrawMatrix.h"
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkAnimateMaker.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkCanvas.h"
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkPaint.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkParse.h"
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkMatrixParts.h"
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScript.h"
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkTypedArray.h"
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comenum SkDrawMatrix_Properties {
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(perspectX),
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(perspectY),
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(rotate),
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(scale),
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(scaleX),
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(scaleY),
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(skewX),
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(skewY),
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(translate),
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(translateX),
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_PROPERTY(translateY)
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if SK_USE_CONDENSED_INFO == 0
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst SkMemberInfo SkDrawMatrix::fInfo[] = {
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_ARRAY(matrix, Float),
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(perspectX, Float),
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(perspectY, Float),
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(rotate, Float),
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(scale, Float),
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(scaleX, Float),
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(scaleY, Float),
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(skewX, Float),
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(skewY, Float),
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(translate, Point),
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(translateX, Float),
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(translateY, Float)
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comDEFINE_GET_MEMBER(SkDrawMatrix);
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
54d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.comSkDrawMatrix::SkDrawMatrix() : fChildHasID(false), fDirty(false) {
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fConcat.reset();
56d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    fMatrix.reset();
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDrawMatrix::~SkDrawMatrix() {
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++)
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        delete *part;
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
641d3c411f5e4d2ad31bc92b3a85957004329ac00dtfarina@chromium.orgbool SkDrawMatrix::addChild(SkAnimateMaker& maker, SkDisplayable* child) {
658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkASSERT(child && child->isMatrixPart());
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkMatrixPart* part = (SkMatrixPart*) child;
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    *fParts.append() = part;
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (part->add())
69d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com        maker.setErrorCode(SkDisplayXMLParserError::kErrorAddingToMatrix);
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return true;
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
73d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.combool SkDrawMatrix::childrenNeedDisposing() const {
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return false;
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkDisplayable* SkDrawMatrix::deepCopy(SkAnimateMaker* maker) {
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDrawMatrix* copy = (SkDrawMatrix*)
798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDisplayType::CreateInstance(maker, SkType_Matrix);
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkASSERT(fParts.count() == 0);
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    copy->fMatrix = fMatrix;
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    copy->fConcat = fConcat;
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return copy;
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
86d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.comvoid SkDrawMatrix::dirty() {
87d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    fDirty = true;
888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool SkDrawMatrix::draw(SkAnimateMaker& maker) {
918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkMatrix& concat = getMatrix();
928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    maker.fCanvas->concat(concat);
938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return false;
948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_DUMP_ENABLED
978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDrawMatrix::dump(SkAnimateMaker* maker) {
988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    dumpBase(maker);
998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (fMatrix.isIdentity()) {
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("matrix=\"identity\"/>\n");
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return;
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar result;
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    result = fMatrix[SkMatrix::kMScaleX];
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result != SK_Scalar1)
1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("sx=\"%g\" ", SkScalarToFloat(result));
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    result = fMatrix.getScaleY();
1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result != SK_Scalar1)
1098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("sy=\"%g\" ", SkScalarToFloat(result));
1108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    result = fMatrix.getSkewX();
1118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result)
1128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("skew-x=\"%g\" ", SkScalarToFloat(result));
1138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    result = fMatrix.getSkewY();
1148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result)
1158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("skew-y=\"%g\" ", SkScalarToFloat(result));
1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    result = fMatrix.getTranslateX();
1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result)
1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("tx=\"%g\" ", SkScalarToFloat(result));
1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    result = fMatrix.getTranslateY();
1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result)
1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("ty=\"%g\" ", SkScalarToFloat(result));
1223f43f8ab9cd3ba0ea83f5ae0659c21f101dfca7areed    result = fMatrix.getPerspX();
1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result)
1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("perspect-x=\"%g\" ", SkScalarToFloat(result));
1253f43f8ab9cd3ba0ea83f5ae0659c21f101dfca7areed    result = fMatrix.getPerspY();
1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (result)
1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("perspect-y=\"%g\" ", SkScalarToFloat(result));
1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDebugf("/>\n");
1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkMatrix& SkDrawMatrix::getMatrix() {
1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (fDirty == false)
1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return fConcat;
1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fMatrix.reset();
1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++) {
1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        (*part)->add();
1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fConcat = fMatrix;
1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fDirty = false;
1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return fConcat;
1428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool SkDrawMatrix::getProperty(int index, SkScriptValue* value) const {
1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    value->fType = SkType_Float;
1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar result;
1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    switch (index) {
1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(perspectX):
1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getPerspX();
1508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(perspectY):
1528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getPerspY();
1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(scaleX):
1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getScaleX();
1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(scaleY):
1588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getScaleY();
1598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(skewX):
1618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getSkewX();
1628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(skewY):
1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getSkewY();
1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(translateX):
1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getTranslateX();
1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(translateY):
1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            result = fMatrix.getTranslateY();
1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        default:
1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//          SkASSERT(0);
1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            return false;
1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    value->fOperand.fScalar = result;
1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return true;
1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDrawMatrix::initialize() {
1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fConcat = fMatrix;
1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkDrawMatrix::onEndElement(SkAnimateMaker& ) {
1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (matrix.count() > 0) {
1868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkScalar* vals = matrix.begin();
1878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fMatrix.setScaleX(vals[0]);
1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fMatrix.setSkewX(vals[1]);
1898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fMatrix.setTranslateX(vals[2]);
1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fMatrix.setSkewY(vals[3]);
1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fMatrix.setScaleY(vals[4]);
1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fMatrix.setTranslateY(vals[5]);
1933f43f8ab9cd3ba0ea83f5ae0659c21f101dfca7areed        fMatrix.setPerspX(vals[6]);
1943f43f8ab9cd3ba0ea83f5ae0659c21f101dfca7areed        fMatrix.setPerspY(vals[7]);
1953f43f8ab9cd3ba0ea83f5ae0659c21f101dfca7areed//      fMatrix.setPerspW(vals[8]);
1968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        goto setConcat;
1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (fChildHasID == false) {
1998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        {
2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            for (SkMatrixPart** part = fParts.begin(); part < fParts.end();  part++)
2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                delete *part;
2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        }
2038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fParts.reset();
2048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comsetConcat:
2058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fConcat = fMatrix;
2068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fDirty = false;
2078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
2098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
210d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.comvoid SkDrawMatrix::setChildHasID() {
211d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    fChildHasID = true;
2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.combool SkDrawMatrix::setProperty(int index, SkScriptValue& scriptValue) {
2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar number = scriptValue.fOperand.fScalar;
2168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    switch (index) {
2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(translate):
2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //      SkScalar xy[2];
2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            SkASSERT(scriptValue.fType == SkType_Array);
2208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            SkASSERT(scriptValue.fOperand.fArray->getType() == SkType_Float);
2218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            SkASSERT(scriptValue.fOperand.fArray->count() == 2);
2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //      SkParse::FindScalars(scriptValue.fOperand.fString->c_str(), xy, 2);
2238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setTranslateX((*scriptValue.fOperand.fArray)[0].fScalar);
2248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setTranslateY((*scriptValue.fOperand.fArray)[1].fScalar);
2258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            return true;
2268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(perspectX):
2273f43f8ab9cd3ba0ea83f5ae0659c21f101dfca7areed            fMatrix.setPerspX(number);
2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(perspectY):
2303f43f8ab9cd3ba0ea83f5ae0659c21f101dfca7areed            fMatrix.setPerspY(number);
2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(rotate): {
2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            SkMatrix temp;
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            temp.setRotate(number, 0, 0);
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setScaleX(temp.getScaleX());
2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setScaleY(temp.getScaleY());
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setSkewX(temp.getSkewX());
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setSkewY(temp.getSkewY());
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            } break;
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(scale):
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setScaleX(number);
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setScaleY(number);
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(scaleX):
2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setScaleX(number);
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(scaleY):
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setScaleY(number);
2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(skewX):
2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setSkewX(number);
2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(skewY):
2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setSkewY(number);
2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(translateX):
2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setTranslateX(number);
2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        case SK_PROPERTY(translateY):
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fMatrix.setTranslateY(number);
2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            break;
2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        default:
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            SkASSERT(0);
2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            return false;
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fConcat = fMatrix;
2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    return true;
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
269