• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "DamageAccumulator.h"
20 #include "FrameInfoVisualizer.h"
21 #include "LayerUpdateQueue.h"
22 #include "Lighting.h"
23 #include "SwapBehavior.h"
24 #include "hwui/Bitmap.h"
25 #include "ColorMode.h"
26 
27 #include <SkRect.h>
28 #include <utils/RefBase.h>
29 
30 class GrDirectContext;
31 
32 struct ANativeWindow;
33 
34 namespace android {
35 
36 namespace uirenderer {
37 
38 class DeferredLayerUpdater;
39 class ErrorHandler;
40 class TaskManager;
41 
42 namespace renderthread {
43 
44 enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
45 
46 class Frame;
47 
48 class IRenderPipeline {
49 public:
50     virtual MakeCurrentResult makeCurrent() = 0;
51     virtual Frame getFrame() = 0;
52     virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
53                       const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
54                       const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
55                       const std::vector<sp<RenderNode>>& renderNodes,
56                       FrameInfoVisualizer* profiler) = 0;
57     virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
58                              FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
59     virtual DeferredLayerUpdater* createTextureLayer() = 0;
60     virtual bool setSurface(ANativeWindow* window, SwapBehavior swapBehavior) = 0;
61     virtual void onStop() = 0;
62     virtual bool isSurfaceReady() = 0;
63     virtual bool isContextReady() = 0;
64     virtual void onDestroyHardwareResources() = 0;
65     virtual void renderLayers(const LightGeometry& lightGeometry,
66                               LayerUpdateQueue* layerUpdateQueue, bool opaque,
67                               const LightInfo& lightInfo) = 0;
68     virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
69                                      ErrorHandler* errorHandler) = 0;
70     virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
71     virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
72     virtual void unpinImages() = 0;
73 
74     virtual void setSurfaceColorProperties(ColorMode colorMode) = 0;
75     virtual SkColorType getSurfaceColorType() const = 0;
76     virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0;
77     virtual GrSurfaceOrigin getSurfaceOrigin() = 0;
78     virtual void setPictureCapturedCallback(
79             const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0;
80 
~IRenderPipeline()81     virtual ~IRenderPipeline() {}
82 };
83 
84 } /* namespace renderthread */
85 } /* namespace uirenderer */
86 } /* namespace android */
87