summaryrefslogtreecommitdiffstats
path: root/libs/hwui/renderthread
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-08-14 09:02:01 -0700
committerJohn Reck <jreck@google.com>2014-08-27 17:44:25 -0700
commit119907cd2575c56b1ebf66348b52e67aaf6a88d8 (patch)
tree9990e37a560021560316ac2cfc6cf4c64df9cb92 /libs/hwui/renderthread
parent1698297daf8068bc9e6971d43744d48f1672bab2 (diff)
downloadframeworks_base-119907cd2575c56b1ebf66348b52e67aaf6a88d8.zip
frameworks_base-119907cd2575c56b1ebf66348b52e67aaf6a88d8.tar.gz
frameworks_base-119907cd2575c56b1ebf66348b52e67aaf6a88d8.tar.bz2
Animator stuff
Bug: 17228458 Change-Id: Id884a429a512f9cd2be0ed16dbd0f10e92b4440d
Diffstat (limited to 'libs/hwui/renderthread')
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp10
-rw-r--r--libs/hwui/renderthread/CanvasContext.h7
-rw-r--r--libs/hwui/renderthread/RenderProxy.cpp9
-rw-r--r--libs/hwui/renderthread/RenderProxy.h3
-rw-r--r--libs/hwui/renderthread/TimeLord.cpp2
-rw-r--r--libs/hwui/renderthread/TimeLord.h2
6 files changed, 23 insertions, 10 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index 4bf5a8a..d9fa0bc 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -21,6 +21,7 @@
#include "EglManager.h"
#include "RenderThread.h"
+#include "../AnimationContext.h"
#include "../Caches.h"
#include "../DeferredLayerUpdater.h"
#include "../RenderState.h"
@@ -35,7 +36,8 @@ namespace android {
namespace uirenderer {
namespace renderthread {
-CanvasContext::CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode)
+CanvasContext::CanvasContext(RenderThread& thread, bool translucent,
+ RenderNode* rootRenderNode, IContextFactory* contextFactory)
: mRenderThread(thread)
, mEglManager(thread.eglManager())
, mEglSurface(EGL_NO_SURFACE)
@@ -44,11 +46,13 @@ CanvasContext::CanvasContext(RenderThread& thread, bool translucent, RenderNode*
, mCanvas(NULL)
, mHaveNewSurface(false)
, mRootRenderNode(rootRenderNode) {
+ mAnimationContext = contextFactory->createAnimationContext(mRenderThread.timeLord());
}
CanvasContext::~CanvasContext() {
destroyCanvasAndSurface();
mRenderThread.removeFrameCallback(this);
+ delete mAnimationContext;
}
void CanvasContext::destroyCanvasAndSurface() {
@@ -136,10 +140,11 @@ void CanvasContext::processLayerUpdate(DeferredLayerUpdater* layerUpdater) {
void CanvasContext::prepareTree(TreeInfo& info) {
mRenderThread.removeFrameCallback(this);
- info.frameTimeMs = mRenderThread.timeLord().frameTimeMs();
info.damageAccumulator = &mDamageAccumulator;
info.renderer = mCanvas;
+ mAnimationContext->startFrame();
mRootRenderNode->prepareTree(info);
+ mAnimationContext->runRemainingAnimations(info);
int runningBehind = 0;
// TODO: This query is moderately expensive, investigate adding some sort
@@ -254,7 +259,6 @@ void CanvasContext::buildLayer(RenderNode* node) {
stopDrawing();
TreeInfo info(TreeInfo::MODE_FULL, mRenderThread.renderState());
- info.frameTimeMs = mRenderThread.timeLord().frameTimeMs();
info.damageAccumulator = &mDamageAccumulator;
info.renderer = mCanvas;
info.runAnimations = false;
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h
index 0cbed6f..749da1b 100644
--- a/libs/hwui/renderthread/CanvasContext.h
+++ b/libs/hwui/renderthread/CanvasContext.h
@@ -25,6 +25,7 @@
#include "../DamageAccumulator.h"
#include "../DrawProfiler.h"
+#include "../IContextFactory.h"
#include "../RenderNode.h"
#include "RenderTask.h"
#include "RenderThread.h"
@@ -34,6 +35,7 @@
namespace android {
namespace uirenderer {
+class AnimationContext;
class DeferredLayerUpdater;
class OpenGLRenderer;
class Rect;
@@ -45,9 +47,11 @@ class EglManager;
// This per-renderer class manages the bridge between the global EGL context
// and the render surface.
+// TODO: Rename to Renderer or some other per-window, top-level manager
class CanvasContext : public IFrameCallback {
public:
- CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode);
+ CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode,
+ IContextFactory* contextFactory);
virtual ~CanvasContext();
bool initialize(ANativeWindow* window);
@@ -105,6 +109,7 @@ private:
OpenGLRenderer* mCanvas;
bool mHaveNewSurface;
DamageAccumulator mDamageAccumulator;
+ AnimationContext* mAnimationContext;
const sp<RenderNode> mRootRenderNode;
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 405ce24..3d04316 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -52,17 +52,20 @@ namespace renderthread {
MethodInvokeRenderTask* task = new MethodInvokeRenderTask((RunnableMethod) Bridge_ ## method); \
ARGS(method) *args = (ARGS(method) *) task->payload()
-CREATE_BRIDGE3(createContext, RenderThread* thread, bool translucent, RenderNode* rootRenderNode) {
- return new CanvasContext(*args->thread, args->translucent, args->rootRenderNode);
+CREATE_BRIDGE4(createContext, RenderThread* thread, bool translucent,
+ RenderNode* rootRenderNode, IContextFactory* contextFactory) {
+ return new CanvasContext(*args->thread, args->translucent,
+ args->rootRenderNode, args->contextFactory);
}
-RenderProxy::RenderProxy(bool translucent, RenderNode* rootRenderNode)
+RenderProxy::RenderProxy(bool translucent, RenderNode* rootRenderNode, IContextFactory* contextFactory)
: mRenderThread(RenderThread::getInstance())
, mContext(0) {
SETUP_TASK(createContext);
args->translucent = translucent;
args->rootRenderNode = rootRenderNode;
args->thread = &mRenderThread;
+ args->contextFactory = contextFactory;
mContext = (CanvasContext*) postAndWait(task);
mDrawFrameTask.setContext(&mRenderThread, mContext);
}
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index eea3674..9e6bcf5 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -30,6 +30,7 @@
#include <utils/Vector.h>
#include "../Caches.h"
+#include "../IContextFactory.h"
#include "DrawFrameTask.h"
namespace android {
@@ -58,7 +59,7 @@ class RenderProxyBridge;
*/
class ANDROID_API RenderProxy {
public:
- ANDROID_API RenderProxy(bool translucent, RenderNode* rootNode);
+ ANDROID_API RenderProxy(bool translucent, RenderNode* rootNode, IContextFactory* contextFactory);
ANDROID_API virtual ~RenderProxy();
ANDROID_API void setFrameInterval(nsecs_t frameIntervalNanos);
diff --git a/libs/hwui/renderthread/TimeLord.cpp b/libs/hwui/renderthread/TimeLord.cpp
index 758d96e..cf3d039 100644
--- a/libs/hwui/renderthread/TimeLord.cpp
+++ b/libs/hwui/renderthread/TimeLord.cpp
@@ -30,7 +30,7 @@ void TimeLord::vsyncReceived(nsecs_t vsync) {
}
}
-nsecs_t TimeLord::frameTimeMs() {
+nsecs_t TimeLord::computeFrameTimeMs() {
// Logic copied from Choreographer.java
nsecs_t now = systemTime(CLOCK_MONOTONIC);
nsecs_t jitterNanos = now - mFrameTimeNanos;
diff --git a/libs/hwui/renderthread/TimeLord.h b/libs/hwui/renderthread/TimeLord.h
index 52c6d9e..8b0372c 100644
--- a/libs/hwui/renderthread/TimeLord.h
+++ b/libs/hwui/renderthread/TimeLord.h
@@ -30,7 +30,7 @@ class TimeLord {
public:
void setFrameInterval(nsecs_t intervalNanos) { mFrameIntervalNanos = intervalNanos; }
void vsyncReceived(nsecs_t vsync);
- nsecs_t frameTimeMs();
+ nsecs_t computeFrameTimeMs();
private:
friend class RenderThread;