blob: b94a7588a5071288215f70ca23c9ae9ac939f522 [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
19#include "FrameInfoVisualizer.h"
John Reckd9d7f122018-05-03 14:40:56 -070020#include "LayerUpdateQueue.h"
John Reckf8441e62017-10-23 13:10:41 -070021#include "SwapBehavior.h"
John Reckd9d7f122018-05-03 14:40:56 -070022#include "hwui/Bitmap.h"
23#include "thread/TaskManager.h"
Stan Iliev768e3932016-07-08 21:34:52 -040024
25#include <SkRect.h>
26#include <utils/RefBase.h>
27
Derek Sollenberger0df62092016-09-27 16:04:42 -040028class GrContext;
29
Stan Iliev768e3932016-07-08 21:34:52 -040030namespace android {
31
32class Surface;
33
34namespace uirenderer {
35
36class DeferredLayerUpdater;
Stan Iliev216b1572018-03-26 14:29:50 -040037class ErrorHandler;
Stan Iliev768e3932016-07-08 21:34:52 -040038
39namespace renderthread {
40
John Reck1bcacfd2017-11-03 10:12:19 -070041enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
Stan Iliev768e3932016-07-08 21:34:52 -040042
Romain Guy26a2b972017-04-17 09:39:51 -070043enum class ColorMode {
44 Srgb,
45 WideColorGamut,
46 // Hdr
47};
48
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;
55 virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
John Reckd9d7f122018-05-03 14:40:56 -070056 const LightGeometry& lightGeometry,
John Reck1bcacfd2017-11-03 10:12:19 -070057 LayerUpdateQueue* layerUpdateQueue, const Rect& contentDrawBounds,
John Reckd9d7f122018-05-03 14:40:56 -070058 bool opaque, bool wideColorGamut, const LightInfo& lightInfo,
John Reck1bcacfd2017-11-03 10:12:19 -070059 const std::vector<sp<RenderNode>>& renderNodes,
60 FrameInfoVisualizer* profiler) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040061 virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
John Reck1bcacfd2017-11-03 10:12:19 -070062 FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040063 virtual bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) = 0;
Derek Sollenberger56ad6ec2016-07-22 12:13:32 -040064 virtual DeferredLayerUpdater* createTextureLayer() = 0;
Romain Guy26a2b972017-04-17 09:39:51 -070065 virtual bool setSurface(Surface* window, SwapBehavior swapBehavior, ColorMode colorMode) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040066 virtual void onStop() = 0;
67 virtual bool isSurfaceReady() = 0;
68 virtual bool isContextReady() = 0;
69 virtual void onDestroyHardwareResources() = 0;
John Reckd9d7f122018-05-03 14:40:56 -070070 virtual void renderLayers(const LightGeometry& lightGeometry,
John Reck1bcacfd2017-11-03 10:12:19 -070071 LayerUpdateQueue* layerUpdateQueue, bool opaque, bool wideColorGamut,
John Reckd9d7f122018-05-03 14:40:56 -070072 const LightInfo& lightInfo) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040073 virtual TaskManager* getTaskManager() = 0;
John Reck1bcacfd2017-11-03 10:12:19 -070074 virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
Stan Iliev216b1572018-03-26 14:29:50 -040075 bool wideColorGamut, ErrorHandler* errorHandler) = 0;
Derek Sollenbergerb7d34b62016-11-04 10:46:18 -040076 virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
77 virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
78 virtual void unpinImages() = 0;
Stan Iliev47fed6ba2017-10-18 17:56:43 -040079 virtual void onPrepareTree() = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040080
81 virtual ~IRenderPipeline() {}
82};
83
84} /* namespace renderthread */
85} /* namespace uirenderer */
86} /* namespace android */