2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Inspired by Rob Johnson's most excellent QuickDraw GX sample code
|
|
|
|
|
|
|
|
#ifndef SkCamera_DEFINED
|
|
|
|
#define SkCamera_DEFINED
|
|
|
|
|
2020-05-17 21:09:43 +00:00
|
|
|
#include "include/core/SkM44.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkMatrix.h"
|
|
|
|
#include "include/private/SkNoncopyable.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2020-04-14 15:35:40 +00:00
|
|
|
// NOTE -- This entire header / impl is deprecated, and will be removed from Skia soon.
|
|
|
|
//
|
|
|
|
// Skia now has support for a 4x matrix (SkM44) in SkCanvas.
|
|
|
|
//
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkCanvas;
|
|
|
|
|
2020-04-14 15:35:40 +00:00
|
|
|
// DEPRECATED
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkPatch3D {
|
|
|
|
public:
|
|
|
|
SkPatch3D();
|
|
|
|
|
|
|
|
void reset();
|
2020-05-17 21:09:43 +00:00
|
|
|
void transform(const SkM44&, SkPatch3D* dst = nullptr) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
// dot a unit vector with the patch's normal
|
|
|
|
SkScalar dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const;
|
2020-05-17 21:09:43 +00:00
|
|
|
SkScalar dotWith(const SkV3& v) const {
|
|
|
|
return this->dotWith(v.x, v.y, v.z);
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
|
2012-05-31 15:29:44 +00:00
|
|
|
// deprecated, but still here for animator (for now)
|
2014-11-14 19:11:46 +00:00
|
|
|
void rotate(SkScalar /*x*/, SkScalar /*y*/, SkScalar /*z*/) {}
|
|
|
|
void rotateDegrees(SkScalar /*x*/, SkScalar /*y*/, SkScalar /*z*/) {}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
public: // make public for SkDraw3D for now
|
2020-05-17 21:09:43 +00:00
|
|
|
SkV3 fU, fV;
|
|
|
|
SkV3 fOrigin;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
friend class SkCamera3D;
|
|
|
|
};
|
|
|
|
|
2020-04-14 15:35:40 +00:00
|
|
|
// DEPRECATED
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkCamera3D {
|
|
|
|
public:
|
|
|
|
SkCamera3D();
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
void update();
|
|
|
|
void patchToMatrix(const SkPatch3D&, SkMatrix* matrix) const;
|
|
|
|
|
2020-05-17 21:09:43 +00:00
|
|
|
SkV3 fLocation; // origin of the camera's space
|
|
|
|
SkV3 fAxis; // view direction
|
|
|
|
SkV3 fZenith; // up direction
|
|
|
|
SkV3 fObserver; // eye position (may not be the same as the origin)
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
mutable SkMatrix fOrientation;
|
|
|
|
mutable bool fNeedToUpdate;
|
|
|
|
|
|
|
|
void doUpdate() const;
|
|
|
|
};
|
|
|
|
|
2020-04-14 15:35:40 +00:00
|
|
|
// DEPRECATED
|
2017-09-20 19:51:08 +00:00
|
|
|
class SK_API Sk3DView : SkNoncopyable {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
Sk3DView();
|
|
|
|
~Sk3DView();
|
|
|
|
|
|
|
|
void save();
|
|
|
|
void restore();
|
|
|
|
|
|
|
|
void translate(SkScalar x, SkScalar y, SkScalar z);
|
|
|
|
void rotateX(SkScalar deg);
|
|
|
|
void rotateY(SkScalar deg);
|
|
|
|
void rotateZ(SkScalar deg);
|
|
|
|
|
2018-11-15 20:54:59 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
2011-03-14 20:30:14 +00:00
|
|
|
void setCameraLocation(SkScalar x, SkScalar y, SkScalar z);
|
2018-11-15 20:54:59 +00:00
|
|
|
SkScalar getCameraLocationX() const;
|
|
|
|
SkScalar getCameraLocationY() const;
|
|
|
|
SkScalar getCameraLocationZ() const;
|
2011-03-14 20:30:14 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
void getMatrix(SkMatrix*) const;
|
|
|
|
void applyToCanvas(SkCanvas*) const;
|
|
|
|
|
|
|
|
SkScalar dotWithNormal(SkScalar dx, SkScalar dy, SkScalar dz) const;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
|
|
|
struct Rec {
|
2020-05-17 21:09:43 +00:00
|
|
|
Rec* fNext;
|
|
|
|
SkM44 fMatrix;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
Rec* fRec;
|
|
|
|
Rec fInitialRec;
|
|
|
|
SkCamera3D fCamera;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|