Merge "Define light position (using new lighting spec) in Java"
This commit is contained in:
@@ -1097,9 +1097,10 @@ public class GLRenderer extends HardwareRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
void setup(int width, int height) {
|
||||
void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) {
|
||||
if (validate()) {
|
||||
mCanvas.setViewport(width, height);
|
||||
mCanvas.initializeLight(lightX, lightY, lightZ, lightRadius);
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
}
|
||||
|
||||
@@ -273,12 +273,16 @@ public abstract class HardwareRenderer {
|
||||
*
|
||||
* @param width Width of the drawing surface.
|
||||
* @param height Height of the drawing surface.
|
||||
* @param lightX X position of the shadow casting light
|
||||
* @param lightY Y position of the shadow casting light
|
||||
* @param lightZ Z position of the shadow casting light
|
||||
* @param lightRadius radius of the shadow casting light
|
||||
*/
|
||||
abstract void setup(int width, int height);
|
||||
abstract void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius);
|
||||
|
||||
/**
|
||||
* Gets the current width of the surface. This is the width that the surface
|
||||
* was last set to in a call to {@link #setup(int, int)}.
|
||||
* was last set to in a call to {@link #setup(int, int, float, float, float, float)}.
|
||||
*
|
||||
* @return the current width of the surface
|
||||
*/
|
||||
@@ -286,7 +290,7 @@ public abstract class HardwareRenderer {
|
||||
|
||||
/**
|
||||
* Gets the current height of the surface. This is the height that the surface
|
||||
* was last set to in a call to {@link #setup(int, int)}.
|
||||
* was last set to in a call to {@link #setup(int, int, float, float, float, float)}.
|
||||
*
|
||||
* @return the current width of the surface
|
||||
*/
|
||||
@@ -310,9 +314,6 @@ public abstract class HardwareRenderer {
|
||||
* whenever system properties are modified. Implementations can use this
|
||||
* to trigger live updates of the renderer based on properties.
|
||||
*
|
||||
* @param surface The surface to update with the new properties.
|
||||
* Can be null.
|
||||
*
|
||||
* @return True if a property has changed.
|
||||
*/
|
||||
abstract boolean loadSystemProperties();
|
||||
@@ -443,17 +444,18 @@ public abstract class HardwareRenderer {
|
||||
* @param width The width of the drawing surface.
|
||||
* @param height The height of the drawing surface.
|
||||
* @param surface The surface to hardware accelerate
|
||||
* @param metrics The display metrics used to draw the output.
|
||||
*
|
||||
* @return true if the surface was initialized, false otherwise. Returning
|
||||
* false might mean that the surface was already initialized.
|
||||
*/
|
||||
boolean initializeIfNeeded(int width, int height, Surface surface)
|
||||
boolean initializeIfNeeded(int width, int height, Surface surface, DisplayMetrics metrics)
|
||||
throws OutOfResourcesException {
|
||||
if (isRequested()) {
|
||||
// We lost the gl context, so recreate it.
|
||||
if (!isEnabled()) {
|
||||
if (initialize(surface)) {
|
||||
setup(width, height);
|
||||
setup(width, height, metrics);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -461,6 +463,14 @@ public abstract class HardwareRenderer {
|
||||
return false;
|
||||
}
|
||||
|
||||
void setup(int width, int height, DisplayMetrics metrics) {
|
||||
float lightX = width / 2.0f;
|
||||
float lightY = -400 * metrics.density;
|
||||
float lightZ = 800 * metrics.density;
|
||||
float lightRadius = 800 * metrics.density;
|
||||
setup(width, height, lightX, lightY, lightZ, lightRadius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional, sets the name of the renderer. Useful for debugging purposes.
|
||||
*
|
||||
|
||||
@@ -145,11 +145,11 @@ public class ThreadedRenderer extends HardwareRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
void setup(int width, int height) {
|
||||
void setup(int width, int height, float lightX, float lightY, float lightZ, float lightRadius) {
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mRootNode.setLeftTopRightBottom(0, 0, mWidth, mHeight);
|
||||
nSetup(mNativeProxy, width, height);
|
||||
nSetup(mNativeProxy, width, height, lightX, lightY, lightZ, lightRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -348,10 +348,9 @@ public class ThreadedRenderer extends HardwareRenderer {
|
||||
private static native boolean nInitialize(long nativeProxy, Surface window);
|
||||
private static native void nUpdateSurface(long nativeProxy, Surface window);
|
||||
private static native void nPauseSurface(long nativeProxy, Surface window);
|
||||
private static native void nSetup(long nativeProxy, int width, int height);
|
||||
private static native void nSetup(long nativeProxy, int width, int height,
|
||||
float lightX, float lightY, float lightZ, float lightRadius);
|
||||
private static native void nSetOpaque(long nativeProxy, boolean opaque);
|
||||
private static native void nSetDisplayListData(long nativeProxy, long displayList,
|
||||
long newData);
|
||||
private static native int nSyncAndDrawFrame(long nativeProxy, long frameTimeNanos,
|
||||
int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom);
|
||||
private static native void nRunWithGlContext(long nativeProxy, Runnable runnable);
|
||||
|
||||
@@ -47,7 +47,6 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
@@ -1714,7 +1713,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
if (hwInitialized ||
|
||||
mWidth != mAttachInfo.mHardwareRenderer.getWidth() ||
|
||||
mHeight != mAttachInfo.mHardwareRenderer.getHeight()) {
|
||||
mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight);
|
||||
mAttachInfo.mHardwareRenderer.setup(mWidth, mHeight,
|
||||
mAttachInfo.mRootView.getResources().getDisplayMetrics());
|
||||
if (!hwInitialized) {
|
||||
mAttachInfo.mHardwareRenderer.invalidate(mSurface);
|
||||
mFullRedrawNeeded = true;
|
||||
@@ -2453,7 +2453,7 @@ public final class ViewRootImpl implements ViewParent,
|
||||
|
||||
try {
|
||||
attachInfo.mHardwareRenderer.initializeIfNeeded(mWidth, mHeight,
|
||||
mSurface);
|
||||
mSurface, attachInfo.mRootView.getResources().getDisplayMetrics());
|
||||
} catch (OutOfResourcesException e) {
|
||||
handleOutOfResourcesException(e);
|
||||
return;
|
||||
@@ -3151,7 +3151,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
mFullRedrawNeeded = true;
|
||||
try {
|
||||
mAttachInfo.mHardwareRenderer.initializeIfNeeded(
|
||||
mWidth, mHeight, mSurface);
|
||||
mWidth, mHeight, mSurface,
|
||||
mAttachInfo.mRootView.getResources().getDisplayMetrics());
|
||||
} catch (OutOfResourcesException e) {
|
||||
Log.e(TAG, "OutOfResourcesException locking surface", e);
|
||||
try {
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <renderthread/RenderProxy.h>
|
||||
#include <renderthread/RenderTask.h>
|
||||
#include <renderthread/RenderThread.h>
|
||||
#include <Vector.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -223,10 +224,11 @@ static void android_view_ThreadedRenderer_pauseSurface(JNIEnv* env, jobject claz
|
||||
proxy->pauseSurface(window);
|
||||
}
|
||||
|
||||
static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz,
|
||||
jlong proxyPtr, jint width, jint height) {
|
||||
static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz, jlong proxyPtr,
|
||||
jint width, jint height,
|
||||
jfloat lightX, jfloat lightY, jfloat lightZ, jfloat lightRadius) {
|
||||
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
|
||||
proxy->setup(width, height);
|
||||
proxy->setup(width, height, Vector3(lightX, lightY, lightZ), lightRadius);
|
||||
}
|
||||
|
||||
static void android_view_ThreadedRenderer_setOpaque(JNIEnv* env, jobject clazz,
|
||||
@@ -316,7 +318,7 @@ static JNINativeMethod gMethods[] = {
|
||||
{ "nInitialize", "(JLandroid/view/Surface;)Z", (void*) android_view_ThreadedRenderer_initialize },
|
||||
{ "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
|
||||
{ "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface },
|
||||
{ "nSetup", "(JII)V", (void*) android_view_ThreadedRenderer_setup },
|
||||
{ "nSetup", "(JIIFFFF)V", (void*) android_view_ThreadedRenderer_setup },
|
||||
{ "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
|
||||
{ "nSyncAndDrawFrame", "(JJIIII)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
|
||||
{ "nDestroyCanvasAndSurface", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvasAndSurface },
|
||||
|
||||
@@ -236,8 +236,12 @@ public class Canvas {
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setViewport(int width, int height) {
|
||||
}
|
||||
public void setViewport(int width, int height) {}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public void initializeLight(float lightX, float lightY, float lightZ, float lightRadius) {}
|
||||
|
||||
/**
|
||||
* Return true if the device that the current layer draws into is opaque
|
||||
|
||||
@@ -688,8 +688,8 @@ TextureVertex* Caches::getRegionMesh() {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Caches::initTempProperties() {
|
||||
propertyAmbientShadowStrength = 25;
|
||||
propertySpotShadowStrength = 25;
|
||||
propertyAmbientShadowStrength = 12;
|
||||
propertySpotShadowStrength = 48;
|
||||
|
||||
propertyLightDiameter = -1.0f;
|
||||
propertyLightPosY = -1.0f;
|
||||
|
||||
@@ -56,10 +56,6 @@ DisplayListData* DisplayListRenderer::finishRecording() {
|
||||
return data;
|
||||
}
|
||||
|
||||
void DisplayListRenderer::setViewport(int width, int height) {
|
||||
initializeViewport(width, height);
|
||||
}
|
||||
|
||||
status_t DisplayListRenderer::prepareDirty(float left, float top,
|
||||
float right, float bottom, bool opaque) {
|
||||
|
||||
|
||||
@@ -33,9 +33,6 @@ namespace uirenderer {
|
||||
// Defines
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define MIN_WRITER_SIZE 4096
|
||||
#define OP_MAY_BE_SKIPPED_MASK 0xff000000
|
||||
|
||||
// Debug
|
||||
#if DEBUG_DISPLAY_LIST
|
||||
#define DISPLAY_LIST_LOGD(...) ALOGD(__VA_ARGS__)
|
||||
@@ -68,7 +65,6 @@ public:
|
||||
// ----------------------------------------------------------------------------
|
||||
// Frame state operations
|
||||
// ----------------------------------------------------------------------------
|
||||
virtual void setViewport(int width, int height);
|
||||
virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
|
||||
virtual void finish();
|
||||
virtual void interrupt();
|
||||
|
||||
@@ -214,7 +214,7 @@ void Layer::defer() {
|
||||
DeferStateStruct deferredState(*deferredList, *renderer,
|
||||
RenderNode::kReplayFlag_ClipChildren);
|
||||
|
||||
renderer->initializeViewport(width, height);
|
||||
renderer->setViewport(width, height);
|
||||
renderer->setupFrameState(dirtyRect.left, dirtyRect.top,
|
||||
dirtyRect.right, dirtyRect.bottom, !isBlend());
|
||||
|
||||
|
||||
@@ -39,10 +39,6 @@ LayerRenderer::LayerRenderer(Layer* layer): mLayer(layer) {
|
||||
LayerRenderer::~LayerRenderer() {
|
||||
}
|
||||
|
||||
void LayerRenderer::setViewport(int width, int height) {
|
||||
initializeViewport(width, height);
|
||||
}
|
||||
|
||||
status_t LayerRenderer::prepareDirty(float left, float top, float right, float bottom,
|
||||
bool opaque) {
|
||||
LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->getFbo());
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
ANDROID_API LayerRenderer(Layer* layer);
|
||||
virtual ~LayerRenderer();
|
||||
|
||||
virtual void setViewport(int width, int height);
|
||||
virtual void onViewportInitialized(int width, int height) { /* do nothing */ }
|
||||
virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
|
||||
virtual status_t clear(float left, float top, float right, float bottom, bool opaque);
|
||||
virtual void finish();
|
||||
|
||||
@@ -161,9 +161,7 @@ void OpenGLRenderer::initProperties() {
|
||||
// Setup
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OpenGLRenderer::setViewport(int width, int height) {
|
||||
initializeViewport(width, height);
|
||||
|
||||
void OpenGLRenderer::onViewportInitialized() {
|
||||
glDisable(GL_DITHER);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
@@ -3240,7 +3238,7 @@ status_t OpenGLRenderer::drawShadow(const mat4& casterTransformXY, const mat4& c
|
||||
VertexBuffer spotShadowVertexBuffer;
|
||||
VertexBufferMode vertexBufferMode = ShadowTessellator::tessellateSpotShadow(
|
||||
isCasterOpaque, casterPolygon, casterVertexCount,
|
||||
*currentTransform(), getWidth(), getHeight(), casterBounds, localClip,
|
||||
*currentTransform(), mLightCenter, mLightRadius, casterBounds, localClip,
|
||||
spotShadowVertexBuffer);
|
||||
drawVertexBuffer(vertexBufferMode, spotShadowVertexBuffer, &paint);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
|
||||
ANDROID_API void initProperties();
|
||||
|
||||
virtual void setViewport(int width, int height);
|
||||
virtual void onViewportInitialized();
|
||||
virtual status_t prepareDirty(float left, float top, float right, float bottom, bool opaque);
|
||||
virtual void finish();
|
||||
virtual void interrupt();
|
||||
|
||||
@@ -88,6 +88,14 @@ public:
|
||||
*/
|
||||
virtual void setViewport(int width, int height) = 0;
|
||||
|
||||
/**
|
||||
* Sets the position and size of the spot shadow casting light.
|
||||
*
|
||||
* @param lightCenter The light's Y position, relative to the render target's top left
|
||||
* @param lightRadius The light's radius
|
||||
*/
|
||||
virtual void initializeLight(const Vector3& lightCenter, float lightRadius) = 0;
|
||||
|
||||
/**
|
||||
* Prepares the renderer to draw a frame. This method must be invoked
|
||||
* at the beginning of each frame. When this method is invoked, the
|
||||
|
||||
@@ -68,47 +68,40 @@ VertexBufferMode ShadowTessellator::tessellateAmbientShadow(bool isCasterOpaque,
|
||||
|
||||
VertexBufferMode ShadowTessellator::tessellateSpotShadow(bool isCasterOpaque,
|
||||
const Vector3* casterPolygon, int casterVertexCount,
|
||||
const mat4& receiverTransform,
|
||||
int screenWidth, int screenHeight, const Rect& casterBounds,
|
||||
const Rect& localClip, VertexBuffer& shadowVertexBuffer) {
|
||||
const mat4& receiverTransform, const Vector3& lightCenter, int lightRadius,
|
||||
const Rect& casterBounds, const Rect& localClip, VertexBuffer& shadowVertexBuffer) {
|
||||
ATRACE_CALL();
|
||||
|
||||
Caches& caches = Caches::getInstance();
|
||||
|
||||
// A bunch of parameters to tweak the shadow.
|
||||
// TODO: Allow some of these changable by debug settings or APIs.
|
||||
int maximal = max(screenWidth, screenHeight);
|
||||
Vector3 lightCenter(screenWidth * 0.5f, 0, maximal);
|
||||
|
||||
Vector3 adjustedLightCenter(lightCenter);
|
||||
if (CC_UNLIKELY(caches.propertyLightPosY > 0)) {
|
||||
lightCenter.y = - caches.propertyLightPosY; // negated since this shifts up
|
||||
adjustedLightCenter.y = - caches.propertyLightPosY; // negated since this shifts up
|
||||
}
|
||||
if (CC_UNLIKELY(caches.propertyLightPosZ > 0)) {
|
||||
lightCenter.z = caches.propertyLightPosZ;
|
||||
adjustedLightCenter.z = caches.propertyLightPosZ;
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG_SHADOW
|
||||
ALOGD("light center %f %f %f", lightCenter.x, lightCenter.y, lightCenter.z);
|
||||
ALOGD("light center %f %f %f",
|
||||
adjustedLightCenter.x, adjustedLightCenter.y, adjustedLightCenter.z);
|
||||
#endif
|
||||
|
||||
// light position (because it's in local space) needs to compensate for receiver transform
|
||||
// TODO: should apply to light orientation, not just position
|
||||
Matrix4 reverseReceiverTransform;
|
||||
reverseReceiverTransform.loadInverse(receiverTransform);
|
||||
reverseReceiverTransform.mapPoint3d(lightCenter);
|
||||
reverseReceiverTransform.mapPoint3d(adjustedLightCenter);
|
||||
|
||||
float lightSize = maximal / 4;
|
||||
const int lightVertexCount = 8;
|
||||
|
||||
if (CC_UNLIKELY(caches.propertyLightDiameter > 0)) {
|
||||
lightSize = caches.propertyLightDiameter;
|
||||
lightRadius = caches.propertyLightDiameter;
|
||||
}
|
||||
|
||||
// Now light and caster are both in local space, we will check whether
|
||||
// the shadow is within the clip area.
|
||||
Rect lightRect = Rect(lightCenter.x - lightSize, lightCenter.y - lightSize,
|
||||
lightCenter.x + lightSize, lightCenter.y + lightSize);
|
||||
Rect lightRect = Rect(adjustedLightCenter.x - lightRadius, adjustedLightCenter.y - lightRadius,
|
||||
adjustedLightCenter.x + lightRadius, adjustedLightCenter.y + lightRadius);
|
||||
lightRect.unionWith(localClip);
|
||||
if (!lightRect.intersects(casterBounds)) {
|
||||
#if DEBUG_SHADOW
|
||||
@@ -118,7 +111,7 @@ VertexBufferMode ShadowTessellator::tessellateSpotShadow(bool isCasterOpaque,
|
||||
}
|
||||
|
||||
VertexBufferMode mode = SpotShadow::createSpotShadow(isCasterOpaque,
|
||||
casterPolygon, casterVertexCount, lightCenter, lightSize,
|
||||
casterPolygon, casterVertexCount, adjustedLightCenter, lightRadius,
|
||||
lightVertexCount, shadowVertexBuffer);
|
||||
|
||||
#if DEBUG_SHADOW
|
||||
|
||||
@@ -73,9 +73,8 @@ public:
|
||||
|
||||
static VertexBufferMode tessellateSpotShadow(bool isCasterOpaque,
|
||||
const Vector3* casterPolygon, int casterVertexCount,
|
||||
const mat4& receiverTransform,
|
||||
int screenWidth, int screenHeight, const Rect& casterBounds,
|
||||
const Rect& localClip, VertexBuffer& shadowVertexBuffer);
|
||||
const mat4& receiverTransform, const Vector3& lightCenter, int lightRadius,
|
||||
const Rect& casterBounds, const Rect& localClip, VertexBuffer& shadowVertexBuffer);
|
||||
|
||||
static void generateShadowIndices(uint16_t* shadowIndices);
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace uirenderer {
|
||||
|
||||
StatefulBaseRenderer::StatefulBaseRenderer() :
|
||||
mDirtyClip(false), mWidth(-1), mHeight(-1),
|
||||
mSaveCount(1), mFirstSnapshot(new Snapshot), mSnapshot(mFirstSnapshot) {
|
||||
mSaveCount(1), mFirstSnapshot(new Snapshot), mSnapshot(mFirstSnapshot),
|
||||
mLightCenter(FLT_MIN, FLT_MIN, FLT_MIN), mLightRadius(FLT_MIN) {
|
||||
}
|
||||
|
||||
void StatefulBaseRenderer::initializeSaveStack(float clipLeft, float clipTop,
|
||||
@@ -37,10 +38,16 @@ void StatefulBaseRenderer::initializeSaveStack(float clipLeft, float clipTop,
|
||||
mSaveCount = 1;
|
||||
}
|
||||
|
||||
void StatefulBaseRenderer::initializeViewport(int width, int height) {
|
||||
void StatefulBaseRenderer::setViewport(int width, int height) {
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mFirstSnapshot->initializeViewport(width, height);
|
||||
onViewportInitialized();
|
||||
}
|
||||
|
||||
void StatefulBaseRenderer::initializeLight(const Vector3& lightCenter, float lightRadius) {
|
||||
mLightCenter = lightCenter;
|
||||
mLightRadius = lightRadius;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -48,10 +48,11 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the first snapshot, computing the projection matrix,
|
||||
* and stores the dimensions of the render target.
|
||||
* Initialize the first snapshot, computing the projection matrix, and stores the dimensions of
|
||||
* the render target.
|
||||
*/
|
||||
void initializeViewport(int width, int height);
|
||||
virtual void setViewport(int width, int height);
|
||||
virtual void initializeLight(const Vector3& lightCenter, float lightRadius);
|
||||
void initializeSaveStack(float clipLeft, float clipTop, float clipRight, float clipBottom);
|
||||
|
||||
// getters
|
||||
@@ -124,6 +125,8 @@ protected:
|
||||
*/
|
||||
virtual void onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) {};
|
||||
|
||||
virtual void onViewportInitialized() {};
|
||||
|
||||
inline const Rect* currentClipRect() const {
|
||||
return mSnapshot->clipRect;
|
||||
}
|
||||
@@ -158,6 +161,9 @@ protected:
|
||||
// TODO: should become private, once hooks needed by OpenGLRenderer are added
|
||||
sp<Snapshot> mSnapshot;
|
||||
|
||||
Vector3 mLightCenter;
|
||||
float mLightRadius;
|
||||
|
||||
}; // class StatefulBaseRenderer
|
||||
|
||||
}; // namespace uirenderer
|
||||
|
||||
@@ -410,9 +410,10 @@ void CanvasContext::pauseSurface(EGLNativeWindowType window) {
|
||||
// and such to prevent from trying to render into this surface
|
||||
}
|
||||
|
||||
void CanvasContext::setup(int width, int height) {
|
||||
void CanvasContext::setup(int width, int height, const Vector3& lightCenter, float lightRadius) {
|
||||
if (!mCanvas) return;
|
||||
mCanvas->setViewport(width, height);
|
||||
mCanvas->initializeLight(lightCenter, lightRadius);
|
||||
}
|
||||
|
||||
void CanvasContext::setOpaque(bool opaque) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
bool initialize(EGLNativeWindowType window);
|
||||
void updateSurface(EGLNativeWindowType window);
|
||||
void pauseSurface(EGLNativeWindowType window);
|
||||
void setup(int width, int height);
|
||||
void setup(int width, int height, const Vector3& lightCenter, float lightRadius);
|
||||
void setOpaque(bool opaque);
|
||||
void makeCurrent();
|
||||
void prepareDraw(const Vector<DeferredLayerUpdater*>* layerUpdaters, TreeInfo& info);
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace renderthread {
|
||||
#define CREATE_BRIDGE2(name, a1, a2) CREATE_BRIDGE(name, a1,a2,,,,,,)
|
||||
#define CREATE_BRIDGE3(name, a1, a2, a3) CREATE_BRIDGE(name, a1,a2,a3,,,,,)
|
||||
#define CREATE_BRIDGE4(name, a1, a2, a3, a4) CREATE_BRIDGE(name, a1,a2,a3,a4,,,,)
|
||||
#define CREATE_BRIDGE5(name, a1, a2, a3, a4, a5) CREATE_BRIDGE(name, a1,a2,a3,a4,a5,,,)
|
||||
#define CREATE_BRIDGE(name, a1, a2, a3, a4, a5, a6, a7, a8) \
|
||||
typedef struct { \
|
||||
a1; a2; a3; a4; a5; a6; a7; a8; \
|
||||
@@ -146,16 +147,19 @@ void RenderProxy::pauseSurface(const sp<ANativeWindow>& window) {
|
||||
postAndWait(task);
|
||||
}
|
||||
|
||||
CREATE_BRIDGE3(setup, CanvasContext* context, int width, int height) {
|
||||
args->context->setup(args->width, args->height);
|
||||
CREATE_BRIDGE5(setup, CanvasContext* context, int width, int height,
|
||||
Vector3 lightCenter, int lightRadius) {
|
||||
args->context->setup(args->width, args->height, args->lightCenter, args->lightRadius);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void RenderProxy::setup(int width, int height) {
|
||||
void RenderProxy::setup(int width, int height, const Vector3& lightCenter, float lightRadius) {
|
||||
SETUP_TASK(setup);
|
||||
args->context = mContext;
|
||||
args->width = width;
|
||||
args->height = height;
|
||||
args->lightCenter = lightCenter;
|
||||
args->lightRadius = lightRadius;
|
||||
post(task);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
ANDROID_API bool initialize(const sp<ANativeWindow>& window);
|
||||
ANDROID_API void updateSurface(const sp<ANativeWindow>& window);
|
||||
ANDROID_API void pauseSurface(const sp<ANativeWindow>& window);
|
||||
ANDROID_API void setup(int width, int height);
|
||||
ANDROID_API void setup(int width, int height, const Vector3& lightCenter, float lightRadius);
|
||||
ANDROID_API void setOpaque(bool opaque);
|
||||
ANDROID_API int syncAndDrawFrame(nsecs_t frameTimeNanos,
|
||||
int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom);
|
||||
|
||||
Reference in New Issue
Block a user