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.

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

mercurial