blob: 0297c9c141ffa14f6f7cf84f76c3ac489fd06e41 [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
Peiyong Lin1f6aa122018-09-10 16:28:08 -070019#include "DamageAccumulator.h"
Stan Iliev768e3932016-07-08 21:34:52 -040020#include "FrameInfoVisualizer.h"
John Reckd9d7f122018-05-03 14:40:56 -070021#include "LayerUpdateQueue.h"
Peiyong Lin1f6aa122018-09-10 16:28:08 -070022#include "Lighting.h"
John Reckf8441e62017-10-23 13:10:41 -070023#include "SwapBehavior.h"
John Reckd9d7f122018-05-03 14:40:56 -070024#include "hwui/Bitmap.h"
Stan Iliev768e3932016-07-08 21:34:52 -040025
26#include <SkRect.h>
27#include <utils/RefBase.h>
28
Derek Sollenberger0df62092016-09-27 16:04:42 -040029class GrContext;
30
Stan Iliev768e3932016-07-08 21:34:52 -040031namespace android {
32
33class Surface;
34
35namespace uirenderer {
36
37class DeferredLayerUpdater;
Stan Iliev216b1572018-03-26 14:29:50 -040038class ErrorHandler;
Peiyong Lin1f6aa122018-09-10 16:28:08 -070039class TaskManager;
Stan Iliev768e3932016-07-08 21:34:52 -040040
41namespace renderthread {
42
John Reck1bcacfd2017-11-03 10:12:19 -070043enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
Stan Iliev768e3932016-07-08 21:34:52 -040044
Romain Guy26a2b972017-04-17 09:39:51 -070045enum class ColorMode {
Peiyong Lin1f6aa122018-09-10 16:28:08 -070046 // Legacy means HWUI will produce buffer with whatever platform prefers
47 // HWUI to produce, however, HWUI doesn't accurately convert color from
48 // source color space to destination color space, instead HWUI will take
49 // the pixel value directly and interpret it destination color space.
50 Legacy,
51 // DisplayColorGamut means HWUI will produce buffer with whatever platform
52 // prefers HWUI to produce and accurately convert color from source color
53 // space to destination color space.
54 DisplayColorGamut,
55 // WideColorGamut means HWUI would support rendering scRGB non-linear into
56 // a signed buffer with enough range to support the wide color gamut of the
57 // display.
Romain Guy26a2b972017-04-17 09:39:51 -070058 WideColorGamut,
59 // Hdr
60};
61
Derek Sollenberger0df62092016-09-27 16:04:42 -040062class Frame;
63
Stan Iliev768e3932016-07-08 21:34:52 -040064class IRenderPipeline {
65public:
66 virtual MakeCurrentResult makeCurrent() = 0;
67 virtual Frame getFrame() = 0;
68 virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
John Reckd9d7f122018-05-03 14:40:56 -070069 const LightGeometry& lightGeometry,
John Reck1bcacfd2017-11-03 10:12:19 -070070 LayerUpdateQueue* layerUpdateQueue, const Rect& contentDrawBounds,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070071 bool opaque, const LightInfo& lightInfo,
John Reck1bcacfd2017-11-03 10:12:19 -070072 const std::vector<sp<RenderNode>>& renderNodes,
73 FrameInfoVisualizer* profiler) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040074 virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
John Reck1bcacfd2017-11-03 10:12:19 -070075 FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
Derek Sollenberger56ad6ec2016-07-22 12:13:32 -040076 virtual DeferredLayerUpdater* createTextureLayer() = 0;
Romain Guy26a2b972017-04-17 09:39:51 -070077 virtual bool setSurface(Surface* window, SwapBehavior swapBehavior, ColorMode colorMode) = 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;
Stan Iliev768e3932016-07-08 21:34:52 -040085 virtual TaskManager* getTaskManager() = 0;
John Reck1bcacfd2017-11-03 10:12:19 -070086 virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070087 ErrorHandler* errorHandler) = 0;
Derek Sollenbergerb7d34b62016-11-04 10:46:18 -040088 virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
89 virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
90 virtual void unpinImages() = 0;
Stan Iliev47fed6ba2017-10-18 17:56:43 -040091 virtual void onPrepareTree() = 0;
Peiyong Lin1f6aa122018-09-10 16:28:08 -070092 virtual SkColorType getSurfaceColorType() const = 0;
93 virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040094
95 virtual ~IRenderPipeline() {}
96};
97
98} /* namespace renderthread */
99} /* namespace uirenderer */
100} /* namespace android */