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 "SkRefCnt.h" 20 #include "pipeline/skia/SkiaGpuPipeline.h" 21 #include "renderstate/RenderState.h" 22 #include "renderthread/HardwareBufferRenderParams.h" 23 #include "renderthread/VulkanManager.h" 24 #include "renderthread/VulkanSurface.h" 25 26 class SkBitmap; 27 struct SkRect; 28 29 namespace android { 30 namespace uirenderer { 31 namespace skiapipeline { 32 33 class SkiaVulkanPipeline : public SkiaGpuPipeline, public IGpuContextCallback { 34 public: 35 explicit SkiaVulkanPipeline(renderthread::RenderThread& thread); 36 virtual ~SkiaVulkanPipeline(); 37 38 renderthread::MakeCurrentResult makeCurrent() override; 39 renderthread::Frame getFrame() override; 40 renderthread::IRenderPipeline::DrawResult draw( 41 const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty, 42 const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue, 43 const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo, 44 const std::vector<sp<RenderNode> >& renderNodes, FrameInfoVisualizer* profiler, 45 const renderthread::HardwareBufferRenderParams& bufferParams, 46 std::mutex& profilerLock) override; getSurfaceOrigin()47 GrSurfaceOrigin getSurfaceOrigin() override { return kTopLeft_GrSurfaceOrigin; } 48 bool swapBuffers(const renderthread::Frame& frame, IRenderPipeline::DrawResult& drawResult, 49 const SkRect& screenDirty, FrameInfo* currentFrameInfo, 50 bool* requireSwap) override; 51 DeferredLayerUpdater* createTextureLayer() override; 52 [[nodiscard]] android::base::unique_fd flush() override; 53 54 bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior) override; 55 void onStop() override; 56 bool isSurfaceReady() override; 57 bool isContextReady() override; 58 void setTargetSdrHdrRatio(float ratio) override; 59 const SkM44& getPixelSnapMatrix() const override; 60 61 static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor); 62 static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread, 63 SkBitmap& skBitmap); 64 65 protected: 66 void onContextDestroyed() override; 67 68 private: 69 renderthread::VulkanManager& vulkanManager(); 70 renderthread::VulkanSurface* mVkSurface = nullptr; 71 sp<ANativeWindow> mNativeWindow; 72 }; 73 74 } /* namespace skiapipeline */ 75 } /* namespace uirenderer */ 76 } /* namespace android */ 77