blob: 77a7ab171ee18a0f19a206869d851ecb28ce1e00 [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"
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050020#include "renderthread/VulkanManager.h"
Derek Sollenbergera19b71a2019-02-15 16:36:30 -050021#include "renderthread/VulkanSurface.h"
Stan Iliev500a0c32016-10-26 10:30:09 -040022
Stan Iliev90276c82019-02-03 18:01:02 -050023#include "renderstate/RenderState.h"
24
Stan Iliev500a0c32016-10-26 10:30:09 -040025namespace android {
26namespace uirenderer {
27namespace skiapipeline {
28
Stan Iliev90276c82019-02-03 18:01:02 -050029class SkiaVulkanPipeline : public SkiaPipeline, public IGpuContextCallback {
Stan Iliev500a0c32016-10-26 10:30:09 -040030public:
Chih-Hung Hsiehf9336412018-12-20 13:48:57 -080031 explicit SkiaVulkanPipeline(renderthread::RenderThread& thread);
Stan Iliev90276c82019-02-03 18:01:02 -050032 virtual ~SkiaVulkanPipeline();
Stan Iliev500a0c32016-10-26 10:30:09 -040033
34 renderthread::MakeCurrentResult makeCurrent() override;
35 renderthread::Frame getFrame() override;
36 bool draw(const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
John Reckd9d7f122018-05-03 14:40:56 -070037 const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
Peiyong Lin1f6aa122018-09-10 16:28:08 -070038 const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
John Reck1bcacfd2017-11-03 10:12:19 -070039 const std::vector<sp<RenderNode> >& renderNodes,
40 FrameInfoVisualizer* profiler) override;
Derek Sollenberger25833d22019-01-14 13:55:55 -050041 GrSurfaceOrigin getSurfaceOrigin() override { return kTopLeft_GrSurfaceOrigin; }
Stan Iliev500a0c32016-10-26 10:30:09 -040042 bool swapBuffers(const renderthread::Frame& frame, bool drew, const SkRect& screenDirty,
John Reck1bcacfd2017-11-03 10:12:19 -070043 FrameInfo* currentFrameInfo, bool* requireSwap) override;
Stan Iliev500a0c32016-10-26 10:30:09 -040044 DeferredLayerUpdater* createTextureLayer() override;
John Reck848f6512018-12-03 13:26:43 -080045 bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior,
John Reck1bcacfd2017-11-03 10:12:19 -070046 renderthread::ColorMode colorMode) override;
Stan Iliev500a0c32016-10-26 10:30:09 -040047 void onStop() override;
48 bool isSurfaceReady() override;
49 bool isContextReady() override;
50
51 static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
Stan Iliev7bc3bc62017-05-24 13:28:36 -040052 static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread,
John Reck1bcacfd2017-11-03 10:12:19 -070053 SkBitmap& skBitmap);
Stan Iliev500a0c32016-10-26 10:30:09 -040054
Stan Iliev90276c82019-02-03 18:01:02 -050055protected:
56 void onContextDestroyed() override;
57
Stan Iliev500a0c32016-10-26 10:30:09 -040058private:
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050059 renderthread::VulkanManager& mVkManager;
60 renderthread::VulkanSurface* mVkSurface = nullptr;
Stan Iliev500a0c32016-10-26 10:30:09 -040061};
62
63} /* namespace skiapipeline */
64} /* namespace uirenderer */
65} /* namespace android */