OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkCamera.h" | 8 #include "SkCamera.h" |
9 | 9 |
10 static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a, | 10 static SkScalar SkScalarDotDiv(int count, const SkScalar a[], int step_a, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 this->reset(); | 67 this->reset(); |
68 } | 68 } |
69 | 69 |
70 void SkPatch3D::reset() { | 70 void SkPatch3D::reset() { |
71 fOrigin.set(0, 0, 0); | 71 fOrigin.set(0, 0, 0); |
72 fU.set(SK_Scalar1, 0, 0); | 72 fU.set(SK_Scalar1, 0, 0); |
73 fV.set(0, -SK_Scalar1, 0); | 73 fV.set(0, -SK_Scalar1, 0); |
74 } | 74 } |
75 | 75 |
76 void SkPatch3D::transform(const SkMatrix3D& m, SkPatch3D* dst) const { | 76 void SkPatch3D::transform(const SkMatrix3D& m, SkPatch3D* dst) const { |
77 if (dst == NULL) { | 77 if (dst == nullptr) { |
78 dst = (SkPatch3D*)this; | 78 dst = (SkPatch3D*)this; |
79 } | 79 } |
80 m.mapVector(fU, &dst->fU); | 80 m.mapVector(fU, &dst->fU); |
81 m.mapVector(fV, &dst->fV); | 81 m.mapVector(fV, &dst->fV); |
82 m.mapPoint(fOrigin, &dst->fOrigin); | 82 m.mapPoint(fOrigin, &dst->fOrigin); |
83 } | 83 } |
84 | 84 |
85 SkScalar SkPatch3D::dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const { | 85 SkScalar SkPatch3D::dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const { |
86 SkScalar cx = SkScalarMul(fU.fY, fV.fZ) - SkScalarMul(fU.fZ, fV.fY); | 86 SkScalar cx = SkScalarMul(fU.fY, fV.fZ) - SkScalarMul(fU.fZ, fV.fY); |
87 SkScalar cy = SkScalarMul(fU.fZ, fV.fX) - SkScalarMul(fU.fX, fV.fY); | 87 SkScalar cy = SkScalarMul(fU.fZ, fV.fX) - SkScalarMul(fU.fX, fV.fY); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 fRec->fMatrix.preRotateZ(deg); | 349 fRec->fMatrix.preRotateZ(deg); |
350 } | 350 } |
351 | 351 |
352 SkScalar Sk3DView::dotWithNormal(SkScalar x, SkScalar y, SkScalar z) const { | 352 SkScalar Sk3DView::dotWithNormal(SkScalar x, SkScalar y, SkScalar z) const { |
353 SkPatch3D patch; | 353 SkPatch3D patch; |
354 patch.transform(fRec->fMatrix); | 354 patch.transform(fRec->fMatrix); |
355 return patch.dotWith(x, y, z); | 355 return patch.dotWith(x, y, z); |
356 } | 356 } |
357 | 357 |
358 void Sk3DView::getMatrix(SkMatrix* matrix) const { | 358 void Sk3DView::getMatrix(SkMatrix* matrix) const { |
359 if (matrix != NULL) { | 359 if (matrix != nullptr) { |
360 SkPatch3D patch; | 360 SkPatch3D patch; |
361 patch.transform(fRec->fMatrix); | 361 patch.transform(fRec->fMatrix); |
362 fCamera.patchToMatrix(patch, matrix); | 362 fCamera.patchToMatrix(patch, matrix); |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 #include "SkCanvas.h" | 366 #include "SkCanvas.h" |
367 | 367 |
368 void Sk3DView::applyToCanvas(SkCanvas* canvas) const { | 368 void Sk3DView::applyToCanvas(SkCanvas* canvas) const { |
369 SkMatrix matrix; | 369 SkMatrix matrix; |
370 | 370 |
371 this->getMatrix(&matrix); | 371 this->getMatrix(&matrix); |
372 canvas->concat(matrix); | 372 canvas->concat(matrix); |
373 } | 373 } |
OLD | NEW |