Home | History | Annotate | Download | only in renderthread
      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 "FrameInfoVisualizer.h"
     20 
     21 #include <SkRect.h>
     22 #include <utils/RefBase.h>
     23 
     24 class GrContext;
     25 
     26 namespace android {
     27 
     28 class Surface;
     29 
     30 namespace uirenderer {
     31 
     32 class DeferredLayerUpdater;
     33 
     34 namespace renderthread {
     35 
     36 enum class SwapBehavior {
     37     kSwap_default,
     38     kSwap_discardBuffer,
     39 };
     40 
     41 enum class MakeCurrentResult {
     42     AlreadyCurrent,
     43     Failed,
     44     Succeeded
     45 };
     46 
     47 enum class ColorMode {
     48     Srgb,
     49     WideColorGamut,
     50     // Hdr
     51 };
     52 
     53 class Frame;
     54 
     55 class IRenderPipeline {
     56 public:
     57     virtual MakeCurrentResult makeCurrent() = 0;
     58     virtual Frame getFrame() = 0;
     59     virtual bool draw(const Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
     60             const FrameBuilder::LightGeometry& lightGeometry,
     61             LayerUpdateQueue* layerUpdateQueue,
     62             const Rect& contentDrawBounds, bool opaque, bool wideColorGamut,
     63             const BakedOpRenderer::LightInfo& lightInfo,
     64             const std::vector< sp<RenderNode> >& renderNodes,
     65             FrameInfoVisualizer* profiler) = 0;
     66     virtual bool swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty,
     67             FrameInfo* currentFrameInfo, bool* requireSwap) = 0;
     68     virtual bool copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) = 0;
     69     virtual DeferredLayerUpdater* createTextureLayer() = 0;
     70     virtual bool setSurface(Surface* window, SwapBehavior swapBehavior, ColorMode colorMode) = 0;
     71     virtual void onStop() = 0;
     72     virtual bool isSurfaceReady() = 0;
     73     virtual bool isContextReady() = 0;
     74     virtual void onDestroyHardwareResources() = 0;
     75     virtual void renderLayers(const FrameBuilder::LightGeometry& lightGeometry,
     76             LayerUpdateQueue* layerUpdateQueue, bool opaque, bool wideColorGamut,
     77             const BakedOpRenderer::LightInfo& lightInfo) = 0;
     78     virtual TaskManager* getTaskManager() = 0;
     79     virtual bool createOrUpdateLayer(RenderNode* node,
     80             const DamageAccumulator& damageAccumulator, bool wideColorGamut) = 0;
     81     virtual bool pinImages(std::vector<SkImage*>& mutableImages) = 0;
     82     virtual bool pinImages(LsaVector<sk_sp<Bitmap>>& images) = 0;
     83     virtual void unpinImages() = 0;
     84 
     85     virtual ~IRenderPipeline() {}
     86 };
     87 
     88 } /* namespace renderthread */
     89 } /* namespace uirenderer */
     90 } /* namespace android */
     91