IRenderPipeline.h revision b7d34b64dd32e3d84bd43344c9c3d9ad098129af
1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include "FrameInfoVisualizer.h"
20#include "EglManager.h"
21
22#include <SkRect.h>
23#include <utils/RefBase.h>
24
25class GrContext;
26
27namespace android {
28
29class Surface;
30
31namespace uirenderer {
32
33class DeferredLayerUpdater;
34
35namespace renderthread {
36
37enum class SwapBehavior {
38    kSwap_default,
39    kSwap_discardBuffer,
40};
41
42enum class MakeCurrentResult {
43    AlreadyCurrent,
44    Failed,
45    Succeeded
46};
47
48class Frame;
49
50class IRenderPipeline {
51public:
52    virtual MakeCurrentResult makeCurrent() = 0;
53    virtual Frame getFrame() = 0;
54    virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
55            const FrameBuilder::LightGeometry& lightGeometry,
56            LayerUpdateQueue* layerUpdateQueue,
57            const Rect& contentDrawBounds, bool opaque,
58            const BakedOpRenderer::LightInfo& lightInfo,
59            const std::vector< sp<RenderNode> >& renderNodes,
60            FrameInfoVisualizer* profiler) = 0;
61    virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
62            FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
63    virtual bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) = 0;
64    virtual DeferredLayerUpdater* createTextureLayer() = 0;
65    virtual bool setSurface(Surface* window, SwapBehavior swapBehavior) = 0;
66    virtual void onStop() = 0;
67    virtual bool isSurfaceReady() = 0;
68    virtual bool isContextReady() = 0;
69    virtual void onDestroyHardwareResources() = 0;
70    virtual void renderLayers(const FrameBuilder::LightGeometry& lightGeometry,
71            LayerUpdateQueue* layerUpdateQueue, bool opaque,
72            const BakedOpRenderer::LightInfo& lightInfo) = 0;
73    virtual TaskManager* getTaskManager() = 0;
74    virtual bool createOrUpdateLayer(RenderNode* node,
75            const DamageAccumulator& damageAccumulator) = 0;
76    virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
77    virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
78    virtual void unpinImages() = 0;
79
80    virtual ~IRenderPipeline() {}
81};
82
83} /* namespace renderthread */
84} /* namespace uirenderer */
85} /* namespace android */
86