blob: a80c613697f26d05c80b3b16f214724275da32b6 [file] [log] [blame]
Stan Iliev500a0c32016-10-26 10:30:09 -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
Alec Mouri43fe6fc2019-12-23 07:46:19 -080019#include <EGL/egl.h>
20#include <system/window.h>
Stan Iliev500a0c32016-10-26 10:30:09 -040021
Alec Mouri43fe6fc2019-12-23 07:46:19 -080022#include "SkiaPipeline.h"
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040023#include "renderstate/RenderState.h"
24
Stan Iliev500a0c32016-10-26 10:30:09 -040025namespace android {
Stan Iliev7bc3bc62017-05-24 13:28:36 -040026
27class Bitmap;
28
Stan Iliev500a0c32016-10-26 10:30:09 -040029namespace uirenderer {
30namespace skiapipeline {
31
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040032class SkiaOpenGLPipeline : public SkiaPipeline, public IGpuContextCallback {
Stan Iliev500a0c32016-10-26 10:30:09 -040033public:
34 SkiaOpenGLPipeline(renderthread::RenderThread& thread);
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040035 virtual ~SkiaOpenGLPipeline();
Stan Iliev500a0c32016-10-26 10:30:09 -040036
37 renderthread::MakeCurrentResult makeCurrent() override;
38 renderthread::Frame getFrame() override;
Alec Mouri3afb3972022-05-27 22:03:11 +000039 renderthread::IRenderPipeline::DrawResult draw(const renderthread::Frame& frame,
40 const SkRect& screenDirty, const SkRect& dirty,
41 const LightGeometry& lightGeometry,
42 LayerUpdateQueue* layerUpdateQueue,
43 const Rect& contentDrawBounds, bool opaque,
44 const LightInfo& lightInfo,
45 const std::vector<sp<RenderNode> >& renderNodes,
46 FrameInfoVisualizer* profiler) override;
Derek Sollenberger25833d22019-01-14 13:55:55 -050047 GrSurfaceOrigin getSurfaceOrigin() override { return kBottomLeft_GrSurfaceOrigin; }
Stan Iliev500a0c32016-10-26 10:30:09 -040048 bool swapBuffers(const renderthread::Frame& frame, bool drew, const SkRect& screenDirty,
John Reck1bcacfd2017-11-03 10:12:19 -070049 FrameInfo* currentFrameInfo, bool* requireSwap) override;
Stan Iliev500a0c32016-10-26 10:30:09 -040050 DeferredLayerUpdater* createTextureLayer() override;
John Reck8ddbc592020-05-07 16:11:18 -070051 bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior) override;
Stan Iliev500a0c32016-10-26 10:30:09 -040052 void onStop() override;
53 bool isSurfaceReady() override;
54 bool isContextReady() override;
55
56 static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
John Reckb90d4cb2018-04-19 17:05:35 -070057
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040058protected:
59 void onContextDestroyed() override;
60
Stan Iliev500a0c32016-10-26 10:30:09 -040061private:
62 renderthread::EglManager& mEglManager;
63 EGLSurface mEglSurface = EGL_NO_SURFACE;
Derek Sollenbergerb8307722022-08-30 14:24:22 -040064 sp<ANativeWindow> mNativeWindow;
65 renderthread::SwapBehavior mSwapBehavior = renderthread::SwapBehavior::kSwap_discardBuffer;
Stan Iliev500a0c32016-10-26 10:30:09 -040066};
67
68} /* namespace skiapipeline */
69} /* namespace uirenderer */
70} /* namespace android */