blob: 3fe0f92b19247c49e3f04a72ef5b81514a4bf6ed [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
19#include "SkiaPipeline.h"
20
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040021#include "renderstate/RenderState.h"
22
Stan Iliev500a0c32016-10-26 10:30:09 -040023namespace android {
Stan Iliev7bc3bc62017-05-24 13:28:36 -040024
25class Bitmap;
26
Stan Iliev500a0c32016-10-26 10:30:09 -040027namespace uirenderer {
28namespace skiapipeline {
29
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040030class SkiaOpenGLPipeline : public SkiaPipeline, public IGpuContextCallback {
Stan Iliev500a0c32016-10-26 10:30:09 -040031public:
32 SkiaOpenGLPipeline(renderthread::RenderThread& thread);
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040033 virtual ~SkiaOpenGLPipeline();
Stan Iliev500a0c32016-10-26 10:30:09 -040034
35 renderthread::MakeCurrentResult makeCurrent() override;
36 renderthread::Frame getFrame() override;
37 bool draw(const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
John Reckd9d7f122018-05-03 14:40:56 -070038 const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070039 const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
John Reck1bcacfd2017-11-03 10:12:19 -070040 const std::vector<sp<RenderNode> >& renderNodes,
41 FrameInfoVisualizer* profiler) override;
Derek Sollenberger25833d22019-01-14 13:55:55 -050042 GrSurfaceOrigin getSurfaceOrigin() override { return kBottomLeft_GrSurfaceOrigin; }
Stan Iliev500a0c32016-10-26 10:30:09 -040043 bool swapBuffers(const renderthread::Frame& frame, bool drew, const SkRect& screenDirty,
John Reck1bcacfd2017-11-03 10:12:19 -070044 FrameInfo* currentFrameInfo, bool* requireSwap) override;
Stan Iliev500a0c32016-10-26 10:30:09 -040045 DeferredLayerUpdater* createTextureLayer() override;
John Reck848f6512018-12-03 13:26:43 -080046 bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior,
John Reck0fa0cbc2019-04-05 16:57:46 -070047 renderthread::ColorMode colorMode, uint32_t extraBuffers) override;
Stan Iliev500a0c32016-10-26 10:30:09 -040048 void onStop() override;
49 bool isSurfaceReady() override;
50 bool isContextReady() override;
51
52 static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
John Reckb90d4cb2018-04-19 17:05:35 -070053
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040054protected:
55 void onContextDestroyed() override;
56
Stan Iliev500a0c32016-10-26 10:30:09 -040057private:
58 renderthread::EglManager& mEglManager;
59 EGLSurface mEglSurface = EGL_NO_SURFACE;
60 bool mBufferPreserved = false;
61};
62
63} /* namespace skiapipeline */
64} /* namespace uirenderer */
65} /* namespace android */