Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 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 | |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 19 | #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 Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 25 | #include "DamageAccumulator.h" |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 26 | #include "FrameInfoVisualizer.h" |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 27 | #include "HardwareBufferRenderParams.h" |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 28 | #include "LayerUpdateQueue.h" |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 29 | #include "Lighting.h" |
John Reck | f8441e6 | 2017-10-23 13:10:41 -0700 | [diff] [blame] | 30 | #include "SwapBehavior.h" |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 31 | #include "hwui/Bitmap.h" |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 32 | |
John Reck | 848f651 | 2018-12-03 13:26:43 -0800 | [diff] [blame] | 33 | struct ANativeWindow; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 34 | |
John Reck | 848f651 | 2018-12-03 13:26:43 -0800 | [diff] [blame] | 35 | namespace android { |
Bo Hu | dd08224 | 2018-12-02 05:22:41 +0000 | [diff] [blame] | 36 | |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 37 | namespace uirenderer { |
| 38 | |
| 39 | class DeferredLayerUpdater; |
Stan Iliev | 216b157 | 2018-03-26 14:29:50 -0400 | [diff] [blame] | 40 | class ErrorHandler; |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 41 | class TaskManager; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 42 | |
| 43 | namespace renderthread { |
| 44 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 45 | enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded }; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 46 | |
Derek Sollenberger | 0df6209 | 2016-09-27 16:04:42 -0400 | [diff] [blame] | 47 | class Frame; |
| 48 | |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 49 | class IRenderPipeline { |
| 50 | public: |
| 51 | virtual MakeCurrentResult makeCurrent() = 0; |
| 52 | virtual Frame getFrame() = 0; |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 53 | |
| 54 | // Result of IRenderPipeline::draw |
| 55 | struct DrawResult { |
| 56 | // True if draw() succeeded, false otherwise |
| 57 | bool success = false; |
| 58 | // If drawing was successful, reports the time at which command |
| 59 | // submission occurred. -1 if this time is unknown. |
| 60 | static constexpr nsecs_t kUnknownTime = -1; |
| 61 | nsecs_t commandSubmissionTime = kUnknownTime; |
John Reck | 5d3fac1 | 2023-11-08 23:08:10 -0500 | [diff] [blame] | 62 | android::base::unique_fd presentFence; |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 63 | }; |
| 64 | virtual DrawResult draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty, |
| 65 | const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue, |
| 66 | const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo, |
| 67 | const std::vector<sp<RenderNode>>& renderNodes, |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 68 | FrameInfoVisualizer* profiler, |
Jiang Tian | e0edc3a | 2024-01-09 11:52:05 +0800 | [diff] [blame] | 69 | const HardwareBufferRenderParams& bufferParams, |
| 70 | std::mutex& profilerLock) = 0; |
John Reck | 5d3fac1 | 2023-11-08 23:08:10 -0500 | [diff] [blame] | 71 | virtual bool swapBuffers(const Frame& frame, IRenderPipeline::DrawResult&, |
| 72 | const SkRect& screenDirty, FrameInfo* currentFrameInfo, |
| 73 | bool* requireSwap) = 0; |
Derek Sollenberger | 56ad6ec | 2016-07-22 12:13:32 -0400 | [diff] [blame] | 74 | virtual DeferredLayerUpdater* createTextureLayer() = 0; |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 75 | [[nodiscard]] virtual android::base::unique_fd flush() = 0; |
| 76 | virtual void setHardwareBuffer(AHardwareBuffer* hardwareBuffer) = 0; |
| 77 | virtual bool hasHardwareBuffer() = 0; |
John Reck | 8ddbc59 | 2020-05-07 16:11:18 -0700 | [diff] [blame] | 78 | virtual bool setSurface(ANativeWindow* window, SwapBehavior swapBehavior) = 0; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 79 | virtual void onStop() = 0; |
| 80 | virtual bool isSurfaceReady() = 0; |
| 81 | virtual bool isContextReady() = 0; |
| 82 | virtual void onDestroyHardwareResources() = 0; |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 83 | virtual void renderLayers(const LightGeometry& lightGeometry, |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 84 | LayerUpdateQueue* layerUpdateQueue, bool opaque, |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 85 | const LightInfo& lightInfo) = 0; |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 86 | virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator, |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 87 | ErrorHandler* errorHandler) = 0; |
Derek Sollenberger | b7d34b6 | 2016-11-04 10:46:18 -0400 | [diff] [blame] | 88 | virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0; |
| 89 | virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0; |
| 90 | virtual void unpinImages() = 0; |
Derek Sollenberger | 1863d94 | 2020-02-05 15:41:51 -0500 | [diff] [blame] | 91 | |
| 92 | virtual void setSurfaceColorProperties(ColorMode colorMode) = 0; |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 93 | virtual SkColorType getSurfaceColorType() const = 0; |
| 94 | virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0; |
John Reck | 5cca8f2 | 2018-12-10 17:06:22 -0800 | [diff] [blame] | 95 | virtual void setPictureCapturedCallback( |
| 96 | const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 97 | |
John Reck | 5588776 | 2023-01-25 16:51:18 -0500 | [diff] [blame] | 98 | virtual void setTargetSdrHdrRatio(float ratio) = 0; |
John Reck | ee18427 | 2023-03-21 12:29:21 -0400 | [diff] [blame] | 99 | virtual const SkM44& getPixelSnapMatrix() const = 0; |
John Reck | 5588776 | 2023-01-25 16:51:18 -0500 | [diff] [blame] | 100 | |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 101 | virtual ~IRenderPipeline() {} |
| 102 | }; |
| 103 | |
| 104 | } /* namespace renderthread */ |
| 105 | } /* namespace uirenderer */ |
| 106 | } /* namespace android */ |