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 | |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 19 | #include "DamageAccumulator.h" |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 20 | #include "FrameInfoVisualizer.h" |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 21 | #include "LayerUpdateQueue.h" |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 22 | #include "Lighting.h" |
John Reck | f8441e6 | 2017-10-23 13:10:41 -0700 | [diff] [blame] | 23 | #include "SwapBehavior.h" |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 24 | #include "hwui/Bitmap.h" |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 25 | |
| 26 | #include <SkRect.h> |
| 27 | #include <utils/RefBase.h> |
| 28 | |
Derek Sollenberger | 0df6209 | 2016-09-27 16:04:42 -0400 | [diff] [blame] | 29 | class GrContext; |
| 30 | |
John Reck | 650bd9a | 2018-11-26 09:52:20 -0800 | [diff] [blame] | 31 | namespace android { |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 32 | |
Bo Hu | dd08224 | 2018-12-02 05:22:41 +0000 | [diff] [blame] | 33 | class Surface; |
| 34 | |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 35 | namespace uirenderer { |
| 36 | |
| 37 | class DeferredLayerUpdater; |
Stan Iliev | 216b157 | 2018-03-26 14:29:50 -0400 | [diff] [blame] | 38 | class ErrorHandler; |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 39 | class TaskManager; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 40 | |
| 41 | namespace renderthread { |
| 42 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 43 | enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded }; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 44 | |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 45 | enum class ColorMode { |
Peiyong Lin | 189021b | 2018-09-27 16:41:40 -0700 | [diff] [blame] | 46 | // SRGB means HWUI will produce buffer in SRGB color space. |
| 47 | SRGB, |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 48 | // WideColorGamut means HWUI would support rendering scRGB non-linear into |
| 49 | // a signed buffer with enough range to support the wide color gamut of the |
| 50 | // display. |
Romain Guy | 26a2b97 | 2017-04-17 09:39:51 -0700 | [diff] [blame] | 51 | WideColorGamut, |
| 52 | // Hdr |
| 53 | }; |
| 54 | |
Derek Sollenberger | 0df6209 | 2016-09-27 16:04:42 -0400 | [diff] [blame] | 55 | class Frame; |
| 56 | |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 57 | class IRenderPipeline { |
| 58 | public: |
| 59 | virtual MakeCurrentResult makeCurrent() = 0; |
| 60 | virtual Frame getFrame() = 0; |
| 61 | virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty, |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 62 | const LightGeometry& lightGeometry, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 63 | LayerUpdateQueue* layerUpdateQueue, const Rect& contentDrawBounds, |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 64 | bool opaque, const LightInfo& lightInfo, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 65 | const std::vector<sp<RenderNode>>& renderNodes, |
| 66 | FrameInfoVisualizer* profiler) = 0; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 67 | virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty, |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 68 | FrameInfo* currentFrameInfo, bool* requireSwap) = 0; |
Derek Sollenberger | 56ad6ec | 2016-07-22 12:13:32 -0400 | [diff] [blame] | 69 | virtual DeferredLayerUpdater* createTextureLayer() = 0; |
Bo Hu | dd08224 | 2018-12-02 05:22:41 +0000 | [diff] [blame] | 70 | virtual bool setSurface(Surface* window, SwapBehavior swapBehavior, ColorMode colorMode) = 0; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 71 | virtual void onStop() = 0; |
| 72 | virtual bool isSurfaceReady() = 0; |
| 73 | virtual bool isContextReady() = 0; |
| 74 | virtual void onDestroyHardwareResources() = 0; |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 75 | virtual void renderLayers(const LightGeometry& lightGeometry, |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 76 | LayerUpdateQueue* layerUpdateQueue, bool opaque, |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 77 | const LightInfo& lightInfo) = 0; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 78 | virtual TaskManager* getTaskManager() = 0; |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 79 | virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator, |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 80 | ErrorHandler* errorHandler) = 0; |
Derek Sollenberger | b7d34b6 | 2016-11-04 10:46:18 -0400 | [diff] [blame] | 81 | virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0; |
| 82 | virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0; |
| 83 | virtual void unpinImages() = 0; |
Stan Iliev | 47fed6ba | 2017-10-18 17:56:43 -0400 | [diff] [blame] | 84 | virtual void onPrepareTree() = 0; |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 85 | virtual SkColorType getSurfaceColorType() const = 0; |
| 86 | virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0; |
Stan Iliev | 768e393 | 2016-07-08 21:34:52 -0400 | [diff] [blame] | 87 | |
| 88 | virtual ~IRenderPipeline() {} |
| 89 | }; |
| 90 | |
| 91 | } /* namespace renderthread */ |
| 92 | } /* namespace uirenderer */ |
| 93 | } /* namespace android */ |