• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #include "renderthread/VulkanManager.h"
21 #include "renderthread/VulkanSurface.h"
22 
23 #include "renderstate/RenderState.h"
24 
25 namespace android {
26 namespace uirenderer {
27 namespace skiapipeline {
28 
29 class SkiaVulkanPipeline : public SkiaPipeline, public IGpuContextCallback {
30 public:
31     explicit SkiaVulkanPipeline(renderthread::RenderThread& thread);
32     virtual ~SkiaVulkanPipeline();
33 
34     renderthread::MakeCurrentResult makeCurrent() override;
35     renderthread::Frame getFrame() override;
36     bool draw(const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
37               const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
38               const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
39               const std::vector<sp<RenderNode> >& renderNodes,
40               FrameInfoVisualizer* profiler) override;
getSurfaceOrigin()41     GrSurfaceOrigin getSurfaceOrigin() override { return kTopLeft_GrSurfaceOrigin; }
42     bool swapBuffers(const renderthread::Frame& frame, bool drew, const SkRect& screenDirty,
43                      FrameInfo* currentFrameInfo, bool* requireSwap) override;
44     DeferredLayerUpdater* createTextureLayer() override;
45     bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior,
46                     renderthread::ColorMode colorMode, uint32_t extraBuffers) override;
47     void onStop() override;
48     bool isSurfaceReady() override;
49     bool isContextReady() override;
50 
51     static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
52     static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread,
53                                                 SkBitmap& skBitmap);
54 
55 protected:
56     void onContextDestroyed() override;
57 
58 private:
59     renderthread::VulkanManager& mVkManager;
60     renderthread::VulkanSurface* mVkSurface = nullptr;
61 };
62 
63 } /* namespace skiapipeline */
64 } /* namespace uirenderer */
65 } /* namespace android */
66