123b797ab5151eb2474f3bdd679f2f07bfd723042John Reck/*
223b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * Copyright (C) 2014 The Android Open Source Project
323b797ab5151eb2474f3bdd679f2f07bfd723042John Reck *
423b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * Licensed under the Apache License, Version 2.0 (the "License");
523b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * you may not use this file except in compliance with the License.
623b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * You may obtain a copy of the License at
723b797ab5151eb2474f3bdd679f2f07bfd723042John Reck *
823b797ab5151eb2474f3bdd679f2f07bfd723042John Reck *      http://www.apache.org/licenses/LICENSE-2.0
923b797ab5151eb2474f3bdd679f2f07bfd723042John Reck *
1023b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * Unless required by applicable law or agreed to in writing, software
1123b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * distributed under the License is distributed on an "AS IS" BASIS,
1223b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1323b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * See the License for the specific language governing permissions and
1423b797ab5151eb2474f3bdd679f2f07bfd723042John Reck * limitations under the License.
1523b797ab5151eb2474f3bdd679f2f07bfd723042John Reck */
1623b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
1723b797ab5151eb2474f3bdd679f2f07bfd723042John Reck#ifndef CANVASCONTEXT_H_
1823b797ab5151eb2474f3bdd679f2f07bfd723042John Reck#define CANVASCONTEXT_H_
1923b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
20ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck#include "DamageAccumulator.h"
21ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck#include "FrameInfo.h"
224c9e59d03c2bca38001225b79d01740b8999adfbJohn Reck#include "FrameInfoVisualizer.h"
23910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales#include "FrameMetricsReporter.h"
240b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#include "IContextFactory.h"
250b7e8245db728d127ada698be63d78b33fc6e4daChris Craik#include "LayerUpdateQueue.h"
26ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck#include "RenderNode.h"
2738f6c034d153bb648d45bce09d80a69ba3e03360John Reck#include "thread/Task.h"
2838f6c034d153bb648d45bce09d80a69ba3e03360John Reck#include "thread/TaskProcessor.h"
29ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck#include "utils/RingBuffer.h"
30ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck#include "renderthread/RenderTask.h"
31ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck#include "renderthread/RenderThread.h"
32998a6d81896df8b662cc10ddeb35087b78b38d72John Reck
3398787e6c9b2c10b1ab7820bdac168686025b924aChris Craik#if HWUI_NEW_OPS
349e7fcfda28fde747ba4e026772007cea77374e16Chris Craik#include "BakedOpDispatcher.h"
3598787e6c9b2c10b1ab7820bdac168686025b924aChris Craik#include "BakedOpRenderer.h"
366e068c0182f6f85bccb855a647510724d1c65a13Chris Craik#include "FrameBuilder.h"
3798787e6c9b2c10b1ab7820bdac168686025b924aChris Craik#endif
3898787e6c9b2c10b1ab7820bdac168686025b924aChris Craik
3923b797ab5151eb2474f3bdd679f2f07bfd723042John Reck#include <cutils/compiler.h>
4023b797ab5151eb2474f3bdd679f2f07bfd723042John Reck#include <EGL/egl.h>
4119b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck#include <SkBitmap.h>
42d04794a9a3f9edc8b7ca336175d66eb81a8f55faJohn Reck#include <SkRect.h>
434f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck#include <utils/Functor.h>
44f648108f83d4e74811919e9811efb8fcc184b8a3John Reck#include <gui/Surface.h>
454f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
4638f6c034d153bb648d45bce09d80a69ba3e03360John Reck#include <functional>
47ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck#include <set>
48b36016c65f1d1b5846dba0349aab491dbd3a746aJohn Reck#include <string>
49ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne#include <vector>
5023b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
5123b797ab5151eb2474f3bdd679f2f07bfd723042John Recknamespace android {
5223b797ab5151eb2474f3bdd679f2f07bfd723042John Recknamespace uirenderer {
534f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
54119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reckclass AnimationContext;
5519b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reckclass DeferredLayerUpdater;
564f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reckclass OpenGLRenderer;
574f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reckclass Rect;
581949e7928eeec22cd3f74b5f763a4eb433238453John Reckclass Layer;
59443a714fa7c0dd07fee3527cc5bc3d3ca1fb7d44John Reckclass RenderState;
604f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
6123b797ab5151eb2474f3bdd679f2f07bfd723042John Recknamespace renderthread {
6223b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
633b20251a355c88193c439f928a84ae69483fb488John Reckclass EglManager;
644f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
651125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reckenum SwapBehavior {
661125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reck    kSwap_default,
671125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reck    kSwap_discardBuffer,
681125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reck};
691125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reck
7023b797ab5151eb2474f3bdd679f2f07bfd723042John Reck// This per-renderer class manages the bridge between the global EGL context
7123b797ab5151eb2474f3bdd679f2f07bfd723042John Reck// and the render surface.
72119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck// TODO: Rename to Renderer or some other per-window, top-level manager
73e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reckclass CanvasContext : public IFrameCallback {
7423b797ab5151eb2474f3bdd679f2f07bfd723042John Reckpublic:
75119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck    CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode,
76119907cd2575c56b1ebf66348b52e67aaf6a88d8John Reck            IContextFactory* contextFactory);
77e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck    virtual ~CanvasContext();
7823b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
791125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reck    // Won't take effect until next EGLSurface creation
801125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reck    void setSwapBehavior(SwapBehavior swapBehavior);
811125d1fa92ab9f3b8315bbfb72e038b62dfd454bJohn Reck
82f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    void initialize(Surface* surface);
83f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    void updateSurface(Surface* surface);
84f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    bool pauseSurface(Surface* surface);
858afcc76920499d0a384dba1470c5a377f80ed768John Reck    void setStopped(bool stopped);
86f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    bool hasSurface() { return mNativeSurface.get(); }
87aa95a88327d9a3ac8a4a00b065b78ac0f28b3a19John Reck
8850210d912925aef14e4ce69be82e4949122a3cd9Alan Viverette    void setup(int width, int height, float lightRadius,
89058fc640017c90120c599d378a4cbc55668b05b7Chris Craik            uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha);
9050210d912925aef14e4ce69be82e4949122a3cd9Alan Viverette    void setLightCenter(const Vector3& lightCenter);
9163a06673253914510bbeebd500655008682dade1John Reck    void setOpaque(bool opaque);
928afcc76920499d0a384dba1470c5a377f80ed768John Reck    bool makeCurrent();
93ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    void prepareTree(TreeInfo& info, int64_t* uiFrameInfo,
94ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne            int64_t syncQueued, RenderNode* target);
95e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck    void draw();
9651f2d606dcbfba3cc5b03dfea37c1304b91c232fJohn Reck    void destroy(TreeObserver* observer);
9723b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
980b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    // IFrameCallback, Choreographer-driven frame callback entry point
99d41c4d8c732095ae99c955b6b82f7306633004b1Chris Craik    virtual void doFrame() override;
100ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    void prepareAndDraw(RenderNode* node);
101e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
10251f2d606dcbfba3cc5b03dfea37c1304b91c232fJohn Reck    void buildLayer(RenderNode* node, TreeObserver* observer);
10319b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck    bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap);
104998a6d81896df8b662cc10ddeb35087b78b38d72John Reck    void markLayerInUse(RenderNode* node);
10519b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck
10651f2d606dcbfba3cc5b03dfea37c1304b91c232fJohn Reck    void destroyHardwareResources(TreeObserver* observer);
107f47a594f5250b1914c36423ee6b371f0b8db09d0John Reck    static void trimMemory(RenderThread& thread, int level);
108e1628b7c6fc3822fa83cf02028ce8ad67abb0afeJohn Reck
1093b20251a355c88193c439f928a84ae69483fb488John Reck    static void invokeFunctor(RenderThread& thread, Functor* functor);
11023b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
111fc53ef27793a39e9effd829e9cae02a9ca14147eJohn Reck    void runWithGlContext(RenderTask* task);
112fc53ef27793a39e9effd829e9cae02a9ca14147eJohn Reck
1131949e7928eeec22cd3f74b5f763a4eb433238453John Reck    Layer* createTextureLayer();
1141949e7928eeec22cd3f74b5f763a4eb433238453John Reck
1153b20251a355c88193c439f928a84ae69483fb488John Reck    ANDROID_API static void setTextureAtlas(RenderThread& thread,
1163b20251a355c88193c439f928a84ae69483fb488John Reck            const sp<GraphicBuffer>& buffer, int64_t* map, size_t mapSize);
11766f0be65a1046f54ddce0498b242c1fa0776b1eaJohn Reck
118f47a594f5250b1914c36423ee6b371f0b8db09d0John Reck    void stopDrawing();
119a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck    void notifyFramePending();
120a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck
1214c9e59d03c2bca38001225b79d01740b8999adfbJohn Reck    FrameInfoVisualizer& profiler() { return mProfiler; }
122fe5e7b7346a54537b980796ceeca66bfdbd05561John Reck
123ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck    void dumpFrames(int fd);
124ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck    void resetFrameStats();
125ba6adf66d3c44c0aa2fd8a224862ff1901d64300John Reck
126b36016c65f1d1b5846dba0349aab491dbd3a746aJohn Reck    void setName(const std::string&& name) { mName = name; }
127b36016c65f1d1b5846dba0349aab491dbd3a746aJohn Reck    const std::string& name() { return mName; }
128b36016c65f1d1b5846dba0349aab491dbd3a746aJohn Reck
129e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck    void serializeDisplayListTree();
130e248bd1b2c3fcf8088429507e73b31f45ee2544bJohn Reck
131ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    void addRenderNode(RenderNode* node, bool placeFront) {
132ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne        int pos = placeFront ? 0 : static_cast<int>(mRenderNodes.size());
1330b7e8245db728d127ada698be63d78b33fc6e4daChris Craik        mRenderNodes.emplace(mRenderNodes.begin() + pos, node);
134ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    }
135ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne
136ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    void removeRenderNode(RenderNode* node) {
137ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne        mRenderNodes.erase(std::remove(mRenderNodes.begin(), mRenderNodes.end(), node),
138ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne                mRenderNodes.end());
139ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    }
140ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne
141b816087962aba0019b022303330f03b897b580edSkuhne    void setContentDrawBounds(int left, int top, int right, int bottom) {
142b816087962aba0019b022303330f03b897b580edSkuhne        mContentDrawBounds.set(left, top, right, bottom);
143ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    }
144ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne
145e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik    RenderState& getRenderState() {
146e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik        return mRenderThread.renderState();
147e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik    }
148e2e53a7079733694bd52dbce665e9ceff21e9727Chris Craik
149910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales    void addFrameMetricsObserver(FrameMetricsObserver* observer) {
150910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales        if (mFrameMetricsReporter.get() == nullptr) {
151910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales            mFrameMetricsReporter.reset(new FrameMetricsReporter());
15206f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales        }
15306f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales
154910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales        mFrameMetricsReporter->addObserver(observer);
15506f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales    }
15606f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales
157910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales    void removeFrameMetricsObserver(FrameMetricsObserver* observer) {
158910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales        if (mFrameMetricsReporter.get() != nullptr) {
159910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales            mFrameMetricsReporter->removeObserver(observer);
160910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales            if (!mFrameMetricsReporter->hasObservers()) {
161910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales                mFrameMetricsReporter.reset(nullptr);
16206f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales            }
16306f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales        }
16406f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales    }
16506f5bc70a667a02b14e31d3f53f91d3661e30666Andres Morales
16638f6c034d153bb648d45bce09d80a69ba3e03360John Reck    // Used to queue up work that needs to be completed before this frame completes
16738f6c034d153bb648d45bce09d80a69ba3e03360John Reck    ANDROID_API void enqueueFrameWork(std::function<void()>&& func);
16838f6c034d153bb648d45bce09d80a69ba3e03360John Reck
16928912a508493e583c48772e2a234e0ed66849490John Reck    ANDROID_API int64_t getFrameNumber();
17028912a508493e583c48772e2a234e0ed66849490John Reck
17123b797ab5151eb2474f3bdd679f2f07bfd723042John Reckprivate:
172a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck    friend class RegisterFrameCallbackTask;
173443a714fa7c0dd07fee3527cc5bc3d3ca1fb7d44John Reck    // TODO: Replace with something better for layer & other GL object
174443a714fa7c0dd07fee3527cc5bc3d3ca1fb7d44John Reck    // lifecycle tracking
175443a714fa7c0dd07fee3527cc5bc3d3ca1fb7d44John Reck    friend class android::uirenderer::RenderState;
176a5dda645da738da7b4ae15e28fa7d93d3b04b94fJohn Reck
177f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    void setSurface(Surface* window);
1784f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
17951f2d606dcbfba3cc5b03dfea37c1304b91c232fJohn Reck    void freePrefetchedLayers(TreeObserver* observer);
180998a6d81896df8b662cc10ddeb35087b78b38d72John Reck
18138f6c034d153bb648d45bce09d80a69ba3e03360John Reck    void waitOnFences();
18238f6c034d153bb648d45bce09d80a69ba3e03360John Reck
18377c40109cf25d29f85ee6c13aeb96e22e55f33abJohn Reck    EGLint mLastFrameWidth = 0;
18477c40109cf25d29f85ee6c13aeb96e22e55f33abJohn Reck    EGLint mLastFrameHeight = 0;
185ddf2215d9807b641dbcb304779ef6b530f876ac7Chris Craik
1864f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    RenderThread& mRenderThread;
1873b20251a355c88193c439f928a84ae69483fb488John Reck    EglManager& mEglManager;
188f648108f83d4e74811919e9811efb8fcc184b8a3John Reck    sp<Surface> mNativeSurface;
189edc524c90506d80e0fc5fb67e8de7b8f3ef53439John Reck    EGLSurface mEglSurface = EGL_NO_SURFACE;
190306f331f91a86da271ce30d4f14d6badf0d25704John Reck    // stopped indicates the CanvasContext will reject actual redraw operations,
191306f331f91a86da271ce30d4f14d6badf0d25704John Reck    // and defer repaint until it is un-stopped
1928afcc76920499d0a384dba1470c5a377f80ed768John Reck    bool mStopped = false;
193306f331f91a86da271ce30d4f14d6badf0d25704John Reck    // CanvasContext is dirty if it has received an update that it has not
194306f331f91a86da271ce30d4f14d6badf0d25704John Reck    // painted onto its surface.
195306f331f91a86da271ce30d4f14d6badf0d25704John Reck    bool mIsDirty = false;
196edc524c90506d80e0fc5fb67e8de7b8f3ef53439John Reck    bool mBufferPreserved = false;
197edc524c90506d80e0fc5fb67e8de7b8f3ef53439John Reck    SwapBehavior mSwapBehavior = kSwap_default;
198e486d932ca5a10446a3c98d6d065213913277268John Reck    struct SwapHistory {
199e486d932ca5a10446a3c98d6d065213913277268John Reck        SkRect damage;
200e486d932ca5a10446a3c98d6d065213913277268John Reck        nsecs_t vsyncTime;
201e486d932ca5a10446a3c98d6d065213913277268John Reck        nsecs_t swapTime;
202e486d932ca5a10446a3c98d6d065213913277268John Reck    };
203e486d932ca5a10446a3c98d6d065213913277268John Reck
204e486d932ca5a10446a3c98d6d065213913277268John Reck    RingBuffer<SwapHistory, 3> mSwapHistory;
20528912a508493e583c48772e2a234e0ed66849490John Reck    int64_t mFrameNumber = -1;
2064f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
2074f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    bool mOpaque;
20898787e6c9b2c10b1ab7820bdac168686025b924aChris Craik#if HWUI_NEW_OPS
20998787e6c9b2c10b1ab7820bdac168686025b924aChris Craik    BakedOpRenderer::LightInfo mLightInfo;
2106e068c0182f6f85bccb855a647510724d1c65a13Chris Craik    FrameBuilder::LightGeometry mLightGeometry = { {0, 0, 0}, 0 };
2116246d27813f25b85f6e4b5cb1121fe8484bcce2dChris Craik#else
2126246d27813f25b85f6e4b5cb1121fe8484bcce2dChris Craik    OpenGLRenderer* mCanvas = nullptr;
21398787e6c9b2c10b1ab7820bdac168686025b924aChris Craik#endif
21498787e6c9b2c10b1ab7820bdac168686025b924aChris Craik
215edc524c90506d80e0fc5fb67e8de7b8f3ef53439John Reck    bool mHaveNewSurface = false;
216e4267ea4f20740c37c01bfb6aefcf61fddc4566aJohn Reck    DamageAccumulator mDamageAccumulator;
2170b7e8245db728d127ada698be63d78b33fc6e4daChris Craik    LayerUpdateQueue mLayerUpdateQueue;
21851d6a3db97bdd5315f1a17a4b447d10a92217b98Chris Craik    std::unique_ptr<AnimationContext> mAnimationContext;
219e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
220ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    std::vector< sp<RenderNode> > mRenderNodes;
221fe5e7b7346a54537b980796ceeca66bfdbd05561John Reck
222edc524c90506d80e0fc5fb67e8de7b8f3ef53439John Reck    FrameInfo* mCurrentFrameInfo = nullptr;
2234c9e59d03c2bca38001225b79d01740b8999adfbJohn Reck    // Ring buffer large enough for 2 seconds worth of frames
2244c9e59d03c2bca38001225b79d01740b8999adfbJohn Reck    RingBuffer<FrameInfo, 120> mFrames;
225b36016c65f1d1b5846dba0349aab491dbd3a746aJohn Reck    std::string mName;
226edc524c90506d80e0fc5fb67e8de7b8f3ef53439John Reck    JankTracker mJankTracker;
2274c9e59d03c2bca38001225b79d01740b8999adfbJohn Reck    FrameInfoVisualizer mProfiler;
228910beb8f5d9042163e2ad0dbb744d9f147db9604Andres Morales    std::unique_ptr<FrameMetricsReporter> mFrameMetricsReporter;
229998a6d81896df8b662cc10ddeb35087b78b38d72John Reck
23051f2d606dcbfba3cc5b03dfea37c1304b91c232fJohn Reck    std::set<RenderNode*> mPrefetchedLayers;
231ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne
232ea7a7fb75acb7305eb774ca7bc7e96103bd49323Skuhne    // Stores the bounds of the main content.
233b816087962aba0019b022303330f03b897b580edSkuhne    Rect mContentDrawBounds;
23438f6c034d153bb648d45bce09d80a69ba3e03360John Reck
23538f6c034d153bb648d45bce09d80a69ba3e03360John Reck    // TODO: This is really a Task<void> but that doesn't really work
23638f6c034d153bb648d45bce09d80a69ba3e03360John Reck    // when Future<> expects to be able to get/set a value
23738f6c034d153bb648d45bce09d80a69ba3e03360John Reck    struct FuncTask : public Task<bool> {
23838f6c034d153bb648d45bce09d80a69ba3e03360John Reck        std::function<void()> func;
23938f6c034d153bb648d45bce09d80a69ba3e03360John Reck    };
24038f6c034d153bb648d45bce09d80a69ba3e03360John Reck    class FuncTaskProcessor;
24138f6c034d153bb648d45bce09d80a69ba3e03360John Reck
24238f6c034d153bb648d45bce09d80a69ba3e03360John Reck    std::vector< sp<FuncTask> > mFrameFences;
24338f6c034d153bb648d45bce09d80a69ba3e03360John Reck    sp<TaskProcessor<bool> > mFrameWorkProcessor;
24423b797ab5151eb2474f3bdd679f2f07bfd723042John Reck};
24523b797ab5151eb2474f3bdd679f2f07bfd723042John Reck
24623b797ab5151eb2474f3bdd679f2f07bfd723042John Reck} /* namespace renderthread */
24723b797ab5151eb2474f3bdd679f2f07bfd723042John Reck} /* namespace uirenderer */
24823b797ab5151eb2474f3bdd679f2f07bfd723042John Reck} /* namespace android */
24923b797ab5151eb2474f3bdd679f2f07bfd723042John Reck#endif /* CANVASCONTEXT_H_ */
250