gfx/skia/trunk/src/animator/SkDraw3D.cpp

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     2 /*
     3  * Copyright 2006 The Android Open Source Project
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
    10 #include "SkDraw3D.h"
    11 #include "SkAnimateMaker.h"
    12 #include "SkCanvas.h"
    13 #include "SkTypedArray.h"
    15 #if SK_USE_CONDENSED_INFO == 0
    17 const SkMemberInfo Sk3D_Point::fInfo[] = {
    18     SK_MEMBER_ALIAS(x, fPoint.fX, Float),
    19     SK_MEMBER_ALIAS(y, fPoint.fY, Float),
    20     SK_MEMBER_ALIAS(z, fPoint.fZ, Float)
    21 };
    23 #endif
    25 DEFINE_NO_VIRTUALS_GET_MEMBER(Sk3D_Point);
    27 Sk3D_Point::Sk3D_Point() {
    28     fPoint.set(0, 0, 0);
    29 }
    31 #if SK_USE_CONDENSED_INFO == 0
    33 const SkMemberInfo Sk3D_Camera::fInfo[] = {
    34     SK_MEMBER_ALIAS(axis, fCamera.fAxis, 3D_Point),
    35     SK_MEMBER(hackHeight, Float),
    36     SK_MEMBER(hackWidth, Float),
    37     SK_MEMBER_ALIAS(location, fCamera.fLocation, 3D_Point),
    38     SK_MEMBER_ALIAS(observer, fCamera.fObserver, 3D_Point),
    39     SK_MEMBER(patch, 3D_Patch),
    40     SK_MEMBER_ALIAS(zenith, fCamera.fZenith, 3D_Point),
    41 };
    43 #endif
    45 DEFINE_GET_MEMBER(Sk3D_Camera);
    47 Sk3D_Camera::Sk3D_Camera() : hackWidth(0), hackHeight(0), patch(NULL) {
    48 }
    50 Sk3D_Camera::~Sk3D_Camera() {
    51 }
    53 bool Sk3D_Camera::draw(SkAnimateMaker& maker) {
    54     fCamera.update();
    55     SkMatrix matrix;
    56     fCamera.patchToMatrix(patch->fPatch, &matrix);
    57     matrix.preTranslate(hackWidth / 2, -hackHeight / 2);
    58     matrix.postTranslate(hackWidth / 2, hackHeight / 2);
    59     maker.fCanvas->concat(matrix);
    60     return false;
    61 }
    64 enum Sk3D_Patch_Functions {
    65     SK_FUNCTION(rotateDegrees)
    66 };
    68 const SkFunctionParamType Sk3D_Patch::fFunctionParameters[] = {
    69     (SkFunctionParamType) SkType_Float,
    70     (SkFunctionParamType) SkType_Float,
    71     (SkFunctionParamType) SkType_Float,
    72     (SkFunctionParamType) 0 // terminator for parameter list (there may be multiple parameter lists)
    73 };
    75 #if SK_USE_CONDENSED_INFO == 0
    77 const SkMemberInfo Sk3D_Patch::fInfo[] = {
    78     SK_MEMBER_ALIAS(origin, fPatch.fOrigin, 3D_Point),
    79     SK_MEMBER_FUNCTION(rotateDegrees, Float),
    80     SK_MEMBER_ALIAS(u, fPatch.fU, 3D_Point),
    81     SK_MEMBER_ALIAS(v, fPatch.fV, 3D_Point)
    82 };
    84 #endif
    86 DEFINE_GET_MEMBER(Sk3D_Patch);
    88 void Sk3D_Patch::executeFunction(SkDisplayable* target, int index,
    89         SkTDArray<SkScriptValue>& parameters, SkDisplayTypes type,
    90         SkScriptValue* ) {
    91     SkASSERT(target == this);
    92     switch (index) {
    93         case SK_FUNCTION(rotateDegrees):
    94             SkASSERT(parameters.count() == 3);
    95             SkASSERT(type == SkType_Float);
    96             fPatch.rotateDegrees(parameters[0].fOperand.fScalar,
    97                 parameters[1].fOperand.fScalar, parameters[2].fOperand.fScalar);
    98             break;
    99         default:
   100             SkASSERT(0);
   101     }
   102 }
   104 const SkFunctionParamType* Sk3D_Patch::getFunctionsParameters() {
   105     return fFunctionParameters;
   106 }

mercurial