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 "pipeline/skia/SkiaPipeline.h"
20 #include "renderthread/Frame.h"
21 
22 namespace android {
23 namespace uirenderer {
24 namespace skiapipeline {
25 
26 class SkiaGpuPipeline : public SkiaPipeline {
27 public:
SkiaGpuPipeline(renderthread::RenderThread & thread)28     SkiaGpuPipeline(renderthread::RenderThread& thread) : SkiaPipeline(thread) {}
~SkiaGpuPipeline()29     ~SkiaGpuPipeline() {}
30 
pinImages(std::vector<SkImage * > & mutableImages)31     bool pinImages(std::vector<SkImage*>& mutableImages) override { return false; }
pinImages(LsaVector<sk_sp<Bitmap>> & images)32     bool pinImages(LsaVector<sk_sp<Bitmap>>& images) override { return false; }
unpinImages()33     void unpinImages() override {}
34 
35     // If the given node didn't have a layer surface, or had one of the wrong size, this method
36     // creates a new one and returns true. Otherwise does nothing and returns false.
createOrUpdateLayer(RenderNode * node,const DamageAccumulator & damageAccumulator,ErrorHandler * errorHandler)37     bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
38                              ErrorHandler* errorHandler) override {
39         return false;
40     }
renderLayersImpl(const LayerUpdateQueue & layers,bool opaque)41     void renderLayersImpl(const LayerUpdateQueue& layers, bool opaque) override {}
setHardwareBuffer(AHardwareBuffer * hardwareBuffer)42     void setHardwareBuffer(AHardwareBuffer* hardwareBuffer) override {}
hasHardwareBuffer()43     bool hasHardwareBuffer() override { return false; }
44 
makeCurrent()45     renderthread::MakeCurrentResult makeCurrent() override {
46         return renderthread::MakeCurrentResult::Failed;
47     }
getFrame()48     renderthread::Frame getFrame() override { return renderthread::Frame(0, 0, 0); }
draw(const renderthread::Frame & frame,const SkRect & screenDirty,const SkRect & dirty,const LightGeometry & lightGeometry,LayerUpdateQueue * layerUpdateQueue,const Rect & contentDrawBounds,bool opaque,const LightInfo & lightInfo,const std::vector<sp<RenderNode>> & renderNodes,FrameInfoVisualizer * profiler,const renderthread::HardwareBufferRenderParams & bufferParams,std::mutex & profilerLock)49     renderthread::IRenderPipeline::DrawResult draw(
50             const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
51             const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
52             const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
53             const std::vector<sp<RenderNode>>& renderNodes, FrameInfoVisualizer* profiler,
54             const renderthread::HardwareBufferRenderParams& bufferParams,
55             std::mutex& profilerLock) override {
56         return {false, IRenderPipeline::DrawResult::kUnknownTime, android::base::unique_fd(-1)};
57     }
swapBuffers(const renderthread::Frame & frame,IRenderPipeline::DrawResult & drawResult,const SkRect & screenDirty,FrameInfo * currentFrameInfo,bool * requireSwap)58     bool swapBuffers(const renderthread::Frame& frame, IRenderPipeline::DrawResult& drawResult,
59                      const SkRect& screenDirty, FrameInfo* currentFrameInfo,
60                      bool* requireSwap) override {
61         return false;
62     }
createTextureLayer()63     DeferredLayerUpdater* createTextureLayer() override { return nullptr; }
setSurface(ANativeWindow * surface,renderthread::SwapBehavior swapBehavior)64     bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior) override {
65         return false;
66     }
flush()67     [[nodiscard]] android::base::unique_fd flush() override {
68         return android::base::unique_fd(-1);
69     };
onStop()70     void onStop() override {}
isSurfaceReady()71     bool isSurfaceReady() override { return false; }
isContextReady()72     bool isContextReady() override { return false; }
73 
getPixelSnapMatrix()74     const SkM44& getPixelSnapMatrix() const override {
75         static const SkM44 sSnapMatrix = SkM44();
76         return sSnapMatrix;
77     }
prepareToDraw(const renderthread::RenderThread & thread,Bitmap * bitmap)78     static void prepareToDraw(const renderthread::RenderThread& thread, Bitmap* bitmap) {}
79 };
80 
81 } /* namespace skiapipeline */
82 } /* namespace uirenderer */
83 } /* namespace android */
84