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 
21 #include <SkRect.h>
22 #include <utils/RefBase.h>
23 
24 class GrContext;
25 
26 namespace android {
27 
28 class Surface;
29 
30 namespace uirenderer {
31 
32 class DeferredLayerUpdater;
33 
34 namespace renderthread {
35 
36 enum class SwapBehavior {
37     kSwap_default,
38     kSwap_discardBuffer,
39 };
40 
41 enum class MakeCurrentResult {
42     AlreadyCurrent,
43     Failed,
44     Succeeded
45 };
46 
47 class Frame;
48 
49 class IRenderPipeline {
50 public:
51     virtual MakeCurrentResult makeCurrent() = 0;
52     virtual Frame getFrame() = 0;
53     virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
54             const FrameBuilder::LightGeometry& lightGeometry,
55             LayerUpdateQueue* layerUpdateQueue,
56             const Rect& contentDrawBounds, bool opaque,
57             const BakedOpRenderer::LightInfo& lightInfo,
58             const std::vector< sp<RenderNode> >& renderNodes,
59             FrameInfoVisualizer* profiler) = 0;
60     virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
61             FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
62     virtual bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) = 0;
63     virtual DeferredLayerUpdater* createTextureLayer() = 0;
64     virtual bool setSurface(Surface* window, SwapBehavior swapBehavior) = 0;
65     virtual void onStop() = 0;
66     virtual bool isSurfaceReady() = 0;
67     virtual bool isContextReady() = 0;
68     virtual void onDestroyHardwareResources() = 0;
69     virtual void renderLayers(const FrameBuilder::LightGeometry& lightGeometry,
70             LayerUpdateQueue* layerUpdateQueue, bool opaque,
71             const BakedOpRenderer::LightInfo& lightInfo) = 0;
72     virtual TaskManager* getTaskManager() = 0;
73     virtual bool createOrUpdateLayer(RenderNode* node,
74             const DamageAccumulator& damageAccumulator) = 0;
75     virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
76     virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
77     virtual void unpinImages() = 0;
78 
~IRenderPipeline()79     virtual ~IRenderPipeline() {}
80 };
81 
82 } /* namespace renderthread */
83 } /* namespace uirenderer */
84 } /* namespace android */
85