blob: aceb5a528fc861a8c35c159838690e7c35e68658 [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"
John Reckb36bfdd2020-07-23 13:47:49 -070025#include "ColorMode.h"
Stan Iliev768e3932016-07-08 21:34:52 -040026
27#include <SkRect.h>
28#include <utils/RefBase.h>
29
Adlai Hollerd2345212020-10-07 14:16:40 -040030class GrDirectContext;
Derek Sollenberger0df62092016-09-27 16:04:42 -040031
John Reck848f6512018-12-03 13:26:43 -080032struct ANativeWindow;
Stan Iliev768e3932016-07-08 21:34:52 -040033
John Reck848f6512018-12-03 13:26:43 -080034namespace android {
Bo Hudd082242018-12-02 05:22:41 +000035
Stan Iliev768e3932016-07-08 21:34:52 -040036namespace uirenderer {
37
38class DeferredLayerUpdater;
Stan Iliev216b1572018-03-26 14:29:50 -040039class ErrorHandler;
Peiyong Lin1f6aa122018-09-10 16:28:08 -070040class TaskManager;
Stan Iliev768e3932016-07-08 21:34:52 -040041
42namespace renderthread {
43
John Reck1bcacfd2017-11-03 10:12:19 -070044enum class MakeCurrentResult { AlreadyCurrent, Failed, Succeeded };
Stan Iliev768e3932016-07-08 21:34:52 -040045
Derek Sollenberger0df62092016-09-27 16:04:42 -040046class Frame;
47
Stan Iliev768e3932016-07-08 21:34:52 -040048class IRenderPipeline {
49public:
50 virtual MakeCurrentResult makeCurrent() = 0;
51 virtual Frame getFrame() = 0;
52 virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
John Reck5cca8f22018-12-10 17:06:22 -080053 const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
54 const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
John Reck1bcacfd2017-11-03 10:12:19 -070055 const std::vector<sp<RenderNode>>& renderNodes,
56 FrameInfoVisualizer* profiler) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040057 virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
John Reck1bcacfd2017-11-03 10:12:19 -070058 FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
Derek Sollenberger56ad6ec2016-07-22 12:13:32 -040059 virtual DeferredLayerUpdater* createTextureLayer() = 0;
John Reck8ddbc592020-05-07 16:11:18 -070060 virtual bool setSurface(ANativeWindow* window, SwapBehavior swapBehavior) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040061 virtual void onStop() = 0;
62 virtual bool isSurfaceReady() = 0;
63 virtual bool isContextReady() = 0;
64 virtual void onDestroyHardwareResources() = 0;
John Reckd9d7f122018-05-03 14:40:56 -070065 virtual void renderLayers(const LightGeometry& lightGeometry,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070066 LayerUpdateQueue* layerUpdateQueue, bool opaque,
John Reckd9d7f122018-05-03 14:40:56 -070067 const LightInfo& lightInfo) = 0;
John Reck1bcacfd2017-11-03 10:12:19 -070068 virtual bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070069 ErrorHandler* errorHandler) = 0;
Derek Sollenbergerb7d34b62016-11-04 10:46:18 -040070 virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
71 virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
72 virtual void unpinImages() = 0;
Derek Sollenberger1863d942020-02-05 15:41:51 -050073
74 virtual void setSurfaceColorProperties(ColorMode colorMode) = 0;
Peiyong Lin1f6aa122018-09-10 16:28:08 -070075 virtual SkColorType getSurfaceColorType() const = 0;
76 virtual sk_sp<SkColorSpace> getSurfaceColorSpace() = 0;
Derek Sollenberger25833d22019-01-14 13:55:55 -050077 virtual GrSurfaceOrigin getSurfaceOrigin() = 0;
John Reck5cca8f22018-12-10 17:06:22 -080078 virtual void setPictureCapturedCallback(
79 const std::function<void(sk_sp<SkPicture>&&)>& callback) = 0;
Stan Iliev768e3932016-07-08 21:34:52 -040080
81 virtual ~IRenderPipeline() {}
82};
83
84} /* namespace renderthread */
85} /* namespace uirenderer */
86} /* namespace android */