• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 
21 namespace android {
22 
23 namespace uirenderer {
24 namespace skiapipeline {
25 
26 class SkiaCpuPipeline : public SkiaPipeline {
27 public:
SkiaCpuPipeline(renderthread::RenderThread & thread)28     SkiaCpuPipeline(renderthread::RenderThread& thread) : SkiaPipeline(thread) {}
~SkiaCpuPipeline()29     ~SkiaCpuPipeline() {}
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.
37     bool createOrUpdateLayer(RenderNode* node, const DamageAccumulator& damageAccumulator,
38                              ErrorHandler* errorHandler) override;
39     void renderLayersImpl(const LayerUpdateQueue& layers, bool opaque) override;
setHardwareBuffer(AHardwareBuffer * hardwareBuffer)40     void setHardwareBuffer(AHardwareBuffer* hardwareBuffer) override {}
hasHardwareBuffer()41     bool hasHardwareBuffer() override { return false; }
42 
43     renderthread::MakeCurrentResult makeCurrent() override;
44     renderthread::Frame getFrame() override;
45     renderthread::IRenderPipeline::DrawResult draw(
46             const renderthread::Frame& frame, const SkRect& screenDirty, const SkRect& dirty,
47             const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue,
48             const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo,
49             const std::vector<sp<RenderNode>>& renderNodes, FrameInfoVisualizer* profiler,
50             const renderthread::HardwareBufferRenderParams& bufferParams,
51             std::mutex& profilerLock) override;
swapBuffers(const renderthread::Frame & frame,IRenderPipeline::DrawResult & drawResult,const SkRect & screenDirty,FrameInfo * currentFrameInfo,bool * requireSwap)52     bool swapBuffers(const renderthread::Frame& frame, IRenderPipeline::DrawResult& drawResult,
53                      const SkRect& screenDirty, FrameInfo* currentFrameInfo,
54                      bool* requireSwap) override {
55         return false;
56     }
createTextureLayer()57     DeferredLayerUpdater* createTextureLayer() override { return nullptr; }
58     bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior) override;
flush()59     [[nodiscard]] android::base::unique_fd flush() override {
60         return android::base::unique_fd(-1);
61     };
onStop()62     void onStop() override {}
isSurfaceReady()63     bool isSurfaceReady() override { return mSurface.get() != nullptr; }
isContextReady()64     bool isContextReady() override { return true; }
65 
getPixelSnapMatrix()66     const SkM44& getPixelSnapMatrix() const override {
67         static const SkM44 sSnapMatrix = SkM44();
68         return sSnapMatrix;
69     }
70 
71 private:
72     sk_sp<SkSurface> mSurface;
73 };
74 
75 } /* namespace skiapipeline */
76 } /* namespace uirenderer */
77 } /* namespace android */
78