Home | History | Annotate | Download | only in skia
      1 /*
      2  * Copyright (C) 2018 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 "FunctorDrawable.h"
     20 
     21 #include <ui/GraphicBuffer.h>
     22 #include <utils/RefBase.h>
     23 
     24 namespace android {
     25 namespace uirenderer {
     26 
     27 namespace skiapipeline {
     28 
     29 /**
     30  * This drawable wraps a Vulkan functor enabling it to be recorded into a list
     31  * of Skia drawing commands.
     32  */
     33 class VkInteropFunctorDrawable : public FunctorDrawable {
     34 public:
     35     using FunctorDrawable::FunctorDrawable;
     36 
     37     virtual ~VkInteropFunctorDrawable();
     38 
     39     static void vkInvokeFunctor(Functor* functor);
     40 
     41     void syncFunctor(const WebViewSyncData& data) const override;
     42 
     43 protected:
     44     virtual void onDraw(SkCanvas* canvas) override;
     45 
     46 private:
     47     // Variables below describe/store temporary offscreen buffer used for Vulkan pipeline.
     48     sp<GraphicBuffer> mFrameBuffer;
     49     SkImageInfo mFBInfo;
     50 };
     51 
     52 }  // namespace skiapipeline
     53 }  // namespace uirenderer
     54 }  // namespace android
     55