void CCamera::NativeApplyToCanvas( /* [in] */ Int64 canvasHandle) { SkCanvas* canvas = reinterpret_cast<NativeCanvas*>(canvasHandle)->getSkCanvas(); Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance); v->applyToCanvas(canvas); }
ECode CCamera::RotateZ( /* [in] */ Float deg) { Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance); v->rotateZ(deg); return NOERROR; }
void CCamera::NativeGetMatrix( /* [in] */ Int64 nativeMatrix) { SkMatrix* native_matrix = reinterpret_cast<SkMatrix*>(nativeMatrix); Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance); v->getMatrix(native_matrix); }
static float Camera_dotWithNormal(JNIEnv* env, jobject obj, float x, float y, float z) { Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); SkScalar dot = v->dotWithNormal(SkFloatToScalar(x), SkFloatToScalar(y), SkFloatToScalar(z)); return SkScalarToFloat(dot); }
virtual void onDrawContent(SkCanvas* canvas) { canvas->translate(this->width()/2, this->height()/2); Sk3DView view; view.rotateX(fRX); view.rotateY(fRY); view.applyToCanvas(canvas); SkPaint paint; if (fShaders.count() > 0) { bool frontFace = view.dotWithNormal(0, 0, SK_Scalar1) < 0; if (frontFace != fFrontFace) { fFrontFace = frontFace; fShaderIndex = (fShaderIndex + 1) % fShaders.count(); } paint.setAntiAlias(true); paint.setShader(fShaders[fShaderIndex]); paint.setFilterLevel(SkPaint::kLow_FilterLevel); SkRect r = { -150, -150, 150, 150 }; canvas->drawRoundRect(r, 30, 30, paint); } fRY += SampleCode::GetAnimSecondsDelta() * 90; if (fRY >= SkIntToScalar(360)) { fRY = 0; } this->inval(NULL); }
static jfloat Camera_dotWithNormal(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) { jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); SkScalar dot = v->dotWithNormal(x, y, z); return SkScalarToFloat(dot); }
static void Camera_rotate(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) { jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->rotateX(x); v->rotateY(y); v->rotateZ(z); }
ECode CCamera::GetLocationX( /* [out] */ Float* locationX) { VALIDATE_NOT_NULL(locationX); Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance); *locationX = SkScalarToFloat(v->getCameraLocationX()); return NOERROR; }
ECode CCamera::SetLocation( /* [in] */ Float x, /* [in] */ Float y, /* [in] */ Float z) { Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance); v->setCameraLocation(x, y, z); return NOERROR; }
ECode CCamera::Rotate( /* [in] */ Float x, /* [in] */ Float y, /* [in] */ Float z) { Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance); v->rotateX(x); v->rotateY(y); v->rotateZ(z); return NOERROR; }
ECode CCamera::DotWithNormal( /* [in] */ Float dx, /* [in] */ Float dy, /* [in] */ Float dz, /* [out] */ Float* result) { VALIDATE_NOT_NULL(result); Sk3DView* v = reinterpret_cast<Sk3DView*>(mNativeInstance); SkScalar dot = v->dotWithNormal(dx, dy, dz); *result = SkScalarToFloat(dot); return NOERROR; }
virtual void onDraw(SkCanvas* canvas) { this->drawBG(canvas); canvas->translate(this->width()/2, this->height()/2); Sk3DView view; view.rotateX(SkIntToScalar(fRX)); view.rotateY(SkIntToScalar(fRY)); view.applyToCanvas(canvas); SkPaint paint; SkScalar rad = SkIntToScalar(50); SkScalar dim = rad*2; if (view.dotWithNormal(0, 0, SK_Scalar1) < 0) { paint.setColor(SK_ColorRED); } paint.setAntiAlias(true); #if 0 SkEmbossMaskFilter::Light light; light.fDirection[0] = SK_Scalar1; light.fDirection[1] = SK_Scalar1; light.fDirection[2] = SK_Scalar1; light.fAmbient = 180; light.fSpecular = 16 * 2; paint.setMaskFilter(new SkEmbossMaskFilter(light, SkIntToScalar(4))); #endif canvas->drawCircle(0, 0, rad, paint); canvas->drawCircle(-dim, -dim, rad, paint); canvas->drawCircle(-dim, dim, rad, paint); canvas->drawCircle( dim, -dim, rad, paint); canvas->drawCircle( dim, dim, rad, paint); fRY += 1; if (fRY >= 360) fRY = 0; this->inval(NULL); }
virtual void onDraw(SkCanvas* canvas) { this->drawBG(canvas); canvas->translate(this->width()/2, this->height()/2); Sk3DView view; view.rotateX(fRX); view.rotateY(fRY); view.applyToCanvas(canvas); SkPaint paint; SkScalar rad = SkIntToScalar(50); SkScalar dim = rad*2; if (fShaders.count() > 0) { bool frontFace = view.dotWithNormal(0, 0, SK_Scalar1) < 0; if (frontFace != fFrontFace) { fFrontFace = frontFace; fShaderIndex = (fShaderIndex + 1) % fShaders.count(); } paint.setAntiAlias(true); paint.setShader(fShaders[fShaderIndex]); #if 0 canvas->drawCircle(0, 0, rad, paint); canvas->drawCircle(-dim, -dim, rad, paint); canvas->drawCircle(-dim, dim, rad, paint); canvas->drawCircle( dim, -dim, rad, paint); canvas->drawCircle( dim, dim, rad, paint); #else SkRect r = { -150, -150, 150, 150 }; canvas->drawRoundRect(r, 30, 30, paint); #endif } fRY += SampleCode::GetAnimSecondsDelta() * 90; if (fRY >= SkIntToScalar(360)) { fRY = 0; } this->inval(NULL); }
virtual void onDrawContent(SkCanvas* canvas) { canvas->translate(this->width()/2, this->height()/2); Sk3DView view; view.rotateX(fRX); view.rotateY(fRY); view.applyToCanvas(canvas); SkPaint paint; if (fShaders.count() > 0) { bool frontFace = view.dotWithNormal(0, 0, SK_Scalar1) < 0; if (frontFace != fFrontFace) { fFrontFace = frontFace; fShaderIndex = (fShaderIndex + 1) % fShaders.count(); } paint.setAntiAlias(true); paint.setShader(fShaders[fShaderIndex]); paint.setFilterQuality(kLow_SkFilterQuality); SkRect r = { -150, -150, 150, 150 }; canvas->drawRoundRect(r, 30, 30, paint); } }
static void Camera_restore(JNIEnv* env, jobject obj) { jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->restore(); }
static void Camera_applyToCanvas(JNIEnv* env, jobject obj, jlong canvasHandle) { SkCanvas* canvas = reinterpret_cast<android::Canvas*>(canvasHandle)->getSkCanvas(); jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->applyToCanvas(canvas); }
static void Camera_getMatrix(JNIEnv* env, jobject obj, jlong matrixHandle) { SkMatrix* native_matrix = reinterpret_cast<SkMatrix*>(matrixHandle); jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->getMatrix(native_matrix); }
static jfloat Camera_getLocationZ(JNIEnv* env, jobject obj) { jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); return SkScalarToFloat(v->getCameraLocationZ()); }
static void Camera_setLocation(JNIEnv* env, jobject obj, jfloat x, jfloat y, jfloat z) { jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->setCameraLocation(x, y, z); }
static void Camera_rotateZ(JNIEnv* env, jobject obj, jfloat degrees) { jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->rotateZ(degrees); }
static void Camera_translate(JNIEnv* env, jobject obj, jfloat dx, jfloat dy, jfloat dz) { jlong viewHandle = env->GetLongField(obj, gNativeInstanceFieldID); Sk3DView* v = reinterpret_cast<Sk3DView*>(viewHandle); v->translate(dx, dy, dz); }
static void Camera_restore(JNIEnv* env, jobject obj) { Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); v->restore(); }
static void Camera_translate(JNIEnv* env, jobject obj, float dx, float dy, float dz) { Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); v->translate(SkFloatToScalar(dx), SkFloatToScalar(dy), SkFloatToScalar(dz)); }
static void Camera_applyToCanvas(JNIEnv* env, jobject obj, int native_canvas) { Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); v->applyToCanvas((SkCanvas*)native_canvas); }
static void Camera_getMatrix(JNIEnv* env, jobject obj, int native_matrix) { Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); v->getMatrix((SkMatrix*)native_matrix); }
static void Camera_rotateZ(JNIEnv* env, jobject obj, float degrees) { Sk3DView* v = (Sk3DView*)env->GetIntField(obj, gNativeInstanceFieldID); v->rotateZ(SkFloatToScalar(degrees)); }