Home | History | Annotate | Download | only in skia
      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 
     22 namespace android {
     23 namespace uirenderer {
     24 namespace skiapipeline {
     25 
     26 class SkiaVulkanPipeline : public SkiaPipeline {
     27 public:
     28     SkiaVulkanPipeline(renderthread::RenderThread& thread);
     29     virtual ~SkiaVulkanPipeline() {}
     30 
     31     renderthread::MakeCurrentResult makeCurrent() override;
     32     renderthread::Frame getFrame() override;
     33     bool draw(const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
     34             const FrameBuilder::LightGeometry& lightGeometry,
     35             LayerUpdateQueue* layerUpdateQueue,
     36             const Rect& contentDrawBounds, bool opaque, bool wideColorGamut,
     37             const BakedOpRenderer::LightInfo& lightInfo,
     38             const std::vector< sp<RenderNode> >& renderNodes,
     39             FrameInfoVisualizer* profiler) override;
     40     bool swapBuffers(const renderthread::Frame& frame, bool drew, const SkRect& screenDirty,
     41             FrameInfo* currentFrameInfo, bool* requireSwap) override;
     42     bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) override;
     43     DeferredLayerUpdater* createTextureLayer() override;
     44     bool setSurface(Surface* window, renderthread::SwapBehavior swapBehavior,
     45             renderthread::ColorMode colorMode) override;
     46     void onStop() override;
     47     bool isSurfaceReady() override;
     48     bool isContextReady() override;
     49 
     50     static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
     51     static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread,
     52             SkBitmap& skBitmap);
     53 
     54 private:
     55     renderthread::VulkanManager& mVkManager;
     56     renderthread::VulkanSurface* mVkSurface = nullptr;
     57 };
     58 
     59 } /* namespace skiapipeline */
     60 } /* namespace uirenderer */
     61 } /* namespace android */
     62