diff options
Diffstat (limited to 'libs/hwui/renderthread/CanvasContext.h')
-rw-r--r-- | libs/hwui/renderthread/CanvasContext.h | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index b0d980b94308..42e9be33d4ea 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -14,14 +14,17 @@ * limitations under the License. */ -#ifndef CANVASCONTEXT_H_ -#define CANVASCONTEXT_H_ +#pragma once +#include "BakedOpDispatcher.h" +#include "BakedOpRenderer.h" #include "DamageAccumulator.h" +#include "FrameBuilder.h" #include "FrameInfo.h" #include "FrameInfoVisualizer.h" #include "FrameMetricsReporter.h" #include "IContextFactory.h" +#include "IRenderPipeline.h" #include "LayerUpdateQueue.h" #include "RenderNode.h" #include "thread/Task.h" @@ -30,12 +33,6 @@ #include "renderthread/RenderTask.h" #include "renderthread/RenderThread.h" -#if HWUI_NEW_OPS -#include "BakedOpDispatcher.h" -#include "BakedOpRenderer.h" -#include "FrameBuilder.h" -#endif - #include <cutils/compiler.h> #include <EGL/egl.h> #include <SkBitmap.h> @@ -53,27 +50,22 @@ namespace uirenderer { class AnimationContext; class DeferredLayerUpdater; -class OpenGLRenderer; -class Rect; class Layer; +class Rect; class RenderState; namespace renderthread { class EglManager; - -enum SwapBehavior { - kSwap_default, - kSwap_discardBuffer, -}; +class Frame; // 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, - IContextFactory* contextFactory); + static CanvasContext* create(RenderThread& thread, bool translucent, + RenderNode* rootRenderNode, IContextFactory* contextFactory); virtual ~CanvasContext(); // Won't take effect until next EGLSurface creation @@ -85,7 +77,7 @@ public: void setStopped(bool stopped); bool hasSurface() { return mNativeSurface.get(); } - void setup(int width, int height, float lightRadius, + void setup(float lightRadius, uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha); void setLightCenter(const Vector3& lightCenter); void setOpaque(bool opaque); @@ -108,8 +100,6 @@ public: static void invokeFunctor(RenderThread& thread, Functor* functor); - void runWithGlContext(RenderTask* task); - Layer* createTextureLayer(); ANDROID_API static void setTextureAtlas(RenderThread& thread, @@ -169,6 +159,9 @@ public: ANDROID_API int64_t getFrameNumber(); private: + CanvasContext(RenderThread& thread, bool translucent, RenderNode* rootRenderNode, + IContextFactory* contextFactory, std::unique_ptr<IRenderPipeline> renderPipeline); + friend class RegisterFrameCallbackTask; // TODO: Replace with something better for layer & other GL object // lifecycle tracking @@ -182,21 +175,20 @@ private: bool isSwapChainStuffed(); + SkRect computeDirtyRect(const Frame& frame, SkRect* dirty); + EGLint mLastFrameWidth = 0; EGLint mLastFrameHeight = 0; RenderThread& mRenderThread; - EglManager& mEglManager; sp<Surface> mNativeSurface; - EGLSurface mEglSurface = EGL_NO_SURFACE; // stopped indicates the CanvasContext will reject actual redraw operations, // and defer repaint until it is un-stopped bool mStopped = false; // CanvasContext is dirty if it has received an update that it has not // painted onto its surface. bool mIsDirty = false; - bool mBufferPreserved = false; - SwapBehavior mSwapBehavior = kSwap_default; + SwapBehavior mSwapBehavior = SwapBehavior::kSwap_default; struct SwapHistory { SkRect damage; nsecs_t vsyncTime; @@ -209,12 +201,8 @@ private: int64_t mFrameNumber = -1; bool mOpaque; -#if HWUI_NEW_OPS BakedOpRenderer::LightInfo mLightInfo; FrameBuilder::LightGeometry mLightGeometry = { {0, 0, 0}, 0 }; -#else - OpenGLRenderer* mCanvas = nullptr; -#endif bool mHaveNewSurface = false; DamageAccumulator mDamageAccumulator; @@ -245,9 +233,9 @@ private: std::vector< sp<FuncTask> > mFrameFences; sp<TaskProcessor<bool> > mFrameWorkProcessor; + std::unique_ptr<IRenderPipeline> mRenderPipeline; }; } /* namespace renderthread */ } /* namespace uirenderer */ } /* namespace android */ -#endif /* CANVASCONTEXT_H_ */ |