skia2/include/utils/SkCamera.h
Kevin Lubick 6c78b8d3ae Revert "Move SkCamera.h to client_utils/android"
This reverts commit 8a54d86c78.

Reason for revert: Causing issues with Android CTS

Original change's description:
> Move SkCamera.h to client_utils/android
>
> Android still uses this
> https://developer.android.com/reference/android/graphics/Camera
> but no other client does.
>
> This adds a little adaption layer until Android is updated
> to use the View3D version.
>
> Move SkCamera.h to View3D.h. Change names to android::skia::CLASS
> instead of SkCLASS. (3DView is not a valid class name, so rename it to
> View3D.)
>
> Forward-declare SkMatrix. Do not override SkNoncopyable - just delete
> the copy constructor/operator=. Make fU and fV private in Patch3D.
>
> Make Sk3DView override View3D temporarily until Android can be switched
> over to the new class.
>
> (View3D from http://review.skia.org/291371)
>
> I made Patch3D and Camera3D be private classes as they are
> currently not used by Android and wanted to constrain the
> exposed API as much as possible.
>
> Change-Id: Ibde45478421feeb610e045205c3f20c0e5b1567e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/532456
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Commit-Queue: Kevin Lubick <kjlubick@google.com>

Change-Id: If6e768524a0e13e14ef886a6f081a09ddc0dc2fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/533396
Owners-Override: Kevin Lubick <kjlubick@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-04-25 12:33:01 +00:00

108 lines
2.5 KiB
C++

/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// Inspired by Rob Johnson's most excellent QuickDraw GX sample code
#ifndef SkCamera_DEFINED
#define SkCamera_DEFINED
#include "include/core/SkM44.h"
#include "include/core/SkMatrix.h"
#include "include/private/SkNoncopyable.h"
// 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.
//
class SkCanvas;
// DEPRECATED
class SkPatch3D {
public:
SkPatch3D();
void reset();
void transform(const SkM44&, SkPatch3D* dst = nullptr) const;
// dot a unit vector with the patch's normal
SkScalar dotWith(SkScalar dx, SkScalar dy, SkScalar dz) const;
SkScalar dotWith(const SkV3& v) const {
return this->dotWith(v.x, v.y, v.z);
}
// deprecated, but still here for animator (for now)
void rotate(SkScalar /*x*/, SkScalar /*y*/, SkScalar /*z*/) {}
void rotateDegrees(SkScalar /*x*/, SkScalar /*y*/, SkScalar /*z*/) {}
private:
public: // make public for SkDraw3D for now
SkV3 fU, fV;
SkV3 fOrigin;
friend class SkCamera3D;
};
// DEPRECATED
class SkCamera3D {
public:
SkCamera3D();
void reset();
void update();
void patchToMatrix(const SkPatch3D&, SkMatrix* matrix) const;
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)
private:
mutable SkMatrix fOrientation;
mutable bool fNeedToUpdate;
void doUpdate() const;
};
// DEPRECATED
class SK_API Sk3DView : SkNoncopyable {
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);
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
void setCameraLocation(SkScalar x, SkScalar y, SkScalar z);
SkScalar getCameraLocationX() const;
SkScalar getCameraLocationY() const;
SkScalar getCameraLocationZ() const;
#endif
void getMatrix(SkMatrix*) const;
void applyToCanvas(SkCanvas*) const;
SkScalar dotWithNormal(SkScalar dx, SkScalar dy, SkScalar dz) const;
private:
struct Rec {
Rec* fNext;
SkM44 fMatrix;
};
Rec* fRec;
Rec fInitialRec;
SkCamera3D fCamera;
};
#endif