• 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 
53     // Result of IRenderPipeline::draw
54     struct DrawResult {
55         // True if draw() succeeded, false otherwise
56         bool success = false;
57         // If drawing was successful, reports the time at which command
58         // submission occurred. -1 if this time is unknown.
59         static constexpr nsecs_t kUnknownTime = -1;
60         nsecs_t commandSubmissionTime = kUnknownTime;
61     };
62     virtual DrawResult draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
63                             const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
64                             const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
65                             const std::vector<sp<RenderNode>>& renderNodes,
66                             FrameInfoVisualizer* profiler) = 0;
67     virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
68                              FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
69     virtual DeferredLayerUpdater* createTextureLayer() = 0;
70     virtual bool setSurface(ANativeWindow* window, SwapBehavior swapBehavior) = 0;
71     virtual void onStop() = 0;
72     virtual bool isSurfaceReady() = 0;
73     virtual bool isContextReady() = 0;
74     virtual void onDestroyHardwareResources() = 0;
75     virtual void renderLayers(const LightGeometry& lightGeometry,
76                               LayerUpdateQueue* layerUpdateQueue, bool opaque,
77                               const LightInfo& lightInfo) = 0;
78     virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
79                                      ErrorHandler* errorHandler) = 0;
80     virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
81     virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
82     virtual void unpinImages() = 0;
83 
84     virtual void setSurfaceColorProperties(ColorMode colorMode) = 0;
85     virtual SkColorType getSurfaceColorType() const = 0;
86     virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0;
87     virtual GrSurfaceOrigin getSurfaceOrigin() = 0;
88     virtual void setPictureCapturedCallback(
89             const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0;
90 
91     virtual const SkM44& getPixelSnapMatrix() const = 0;
92 
~IRenderPipeline()93     virtual ~IRenderPipeline() {}
94 };
95 
96 } /* namespace renderthread */
97 } /* namespace uirenderer */
98 } /* namespace android */
99