blob: 9ebad81c5c817ed3263636ae2f3fcf34e8dc74bc [file] [log] [blame]
Stan Iliev768e3932016-07-08 21:34:52 -04001/*
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
Nader Jawada3521852023-01-30 20:23:46 -080019#include <SkColorSpace.h>
20#include <SkRect.h>
21#include <android-base/unique_fd.h>
22#include <utils/RefBase.h>
23
24#include "ColorMode.h"
Peiyong Lin1f6aa122018-09-10 16:28:08 -070025#include "DamageAccumulator.h"
Stan Iliev768e3932016-07-08 21:34:52 -040026#include "FrameInfoVisualizer.h"
Nader Jawada3521852023-01-30 20:23:46 -080027#include "HardwareBufferRenderParams.h"
John Reckd9d7f122018-05-03 14:40:56 -070028#include "LayerUpdateQueue.h"
Peiyong Lin1f6aa122018-09-10 16:28:08 -070029#include "Lighting.h"
John Reckf8441e62017-10-23 13:10:41 -070030#include "SwapBehavior.h"
John Reckd9d7f122018-05-03 14:40:56 -070031#include "hwui/Bitmap.h"
Stan Iliev768e3932016-07-08 21:34:52 -040032
Adlai Hollerd2345212020-10-07 14:16:40 -040033class GrDirectContext;
Derek Sollenberger0df62092016-09-27 16:04:42 -040034
John Reck848f6512018-12-03 13:26:43 -080035struct ANativeWindow;
Stan Iliev768e3932016-07-08 21:34:52 -040036
John Reck848f6512018-12-03 13:26:43 -080037namespace android {
Bo Hudd082242018-12-02 05:22:41 +000038
Stan Iliev768e3932016-07-08 21:34:52 -040039namespace uirenderer {
40
41class DeferredLayerUpdater;
Stan Iliev216b1572018-03-26 14:29:50 -040042class ErrorHandler;
Peiyong Lin1f6aa122018-09-10 16:28:08 -070043class TaskManager;
Stan Iliev768e3932016-07-08 21:34:52 -040044
45namespace renderthread {
46
John Reck1bcacfd2017-11-03 10:12:19 -070047enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
Stan Iliev768e3932016-07-08 21:34:52 -040048
Derek Sollenberger0df62092016-09-27 16:04:42 -040049class Frame;
50
Stan Iliev768e3932016-07-08 21:34:52 -040051class IRenderPipeline {
52public:
53 virtual MakeCurrentResult makeCurrent() = 0;
54 virtual Frame getFrame() = 0;
Alec Mouri3afb3972022-05-27 22:03:11 +000055
56 // Result of IRenderPipeline::draw
57 struct DrawResult {
58 // True if draw() succeeded, false otherwise
59 bool success = false;
60 // If drawing was successful, reports the time at which command
61 // submission occurred. -1 if this time is unknown.
62 static constexpr nsecs_t kUnknownTime = -1;
63 nsecs_t commandSubmissionTime = kUnknownTime;
64 };
65 virtual DrawResult draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
66 const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
67 const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
68 const std::vector<sp<RenderNode>>& renderNodes,
Nader Jawada3521852023-01-30 20:23:46 -080069 FrameInfoVisualizer* profiler,
70 const HardwareBufferRenderParams& bufferParams) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040071 virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
John Reck1bcacfd2017-11-03 10:12:19 -070072 FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
Derek Sollenberger56ad6ec2016-07-22 12:13:32 -040073 virtual DeferredLayerUpdater* createTextureLayer() = 0;
Nader Jawada3521852023-01-30 20:23:46 -080074 [[nodiscard]] virtual android::base::unique_fd flush() = 0;
75 virtual void setHardwareBuffer(AHardwareBuffer* hardwareBuffer) = 0;
76 virtual bool hasHardwareBuffer() = 0;
John Reck8ddbc592020-05-07 16:11:18 -070077 virtual bool setSurface(ANativeWindow* window, SwapBehavior swapBehavior) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040078 virtual void onStop() = 0;
79 virtual bool isSurfaceReady() = 0;
80 virtual bool isContextReady() = 0;
81 virtual void onDestroyHardwareResources() = 0;
John Reckd9d7f122018-05-03 14:40:56 -070082 virtual void renderLayers(const LightGeometry& lightGeometry,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070083 LayerUpdateQueue* layerUpdateQueue, bool opaque,
John Reckd9d7f122018-05-03 14:40:56 -070084 const LightInfo& lightInfo) = 0;
John Reck1bcacfd2017-11-03 10:12:19 -070085 virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070086 ErrorHandler* errorHandler) = 0;
Derek Sollenbergerb7d34b62016-11-04 10:46:18 -040087 virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
88 virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
89 virtual void unpinImages() = 0;
Derek Sollenberger1863d942020-02-05 15:41:51 -050090
91 virtual void setSurfaceColorProperties(ColorMode colorMode) = 0;
Peiyong Lin1f6aa122018-09-10 16:28:08 -070092 virtual SkColorType getSurfaceColorType() const = 0;
93 virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0;
Derek Sollenberger25833d22019-01-14 13:55:55 -050094 virtual GrSurfaceOrigin getSurfaceOrigin() = 0;
John Reck5cca8f22018-12-10 17:06:22 -080095 virtual void setPictureCapturedCallback(
96 const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040097
John Reck55887762023-01-25 16:51:18 -050098 virtual bool supportsExtendedRangeHdr() const { return false; }
99 virtual void setTargetSdrHdrRatio(float ratio) = 0;
John Reckee184272023-03-21 12:29:21 -0400100 virtual const SkM44& getPixelSnapMatrix() const = 0;
John Reck55887762023-01-25 16:51:18 -0500101
Stan Iliev768e3932016-07-08 21:34:52 -0400102 virtual ~IRenderPipeline() {}
103};
104
105} /* namespace renderthread */
106} /* namespace uirenderer */
107} /* namespace android */