blob: 5a1014c2c2deeb9c29f0727d24c9f2ed8b967a3f [file] [log] [blame]
Jerome Gaillardbea67ce2024-03-28 14:21:16 +00001/*
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
21namespace android {
22
23namespace uirenderer {
24namespace skiapipeline {
25
26class SkiaCpuPipeline : public SkiaPipeline {
27public:
28 SkiaCpuPipeline(renderthread::RenderThread& thread) : SkiaPipeline(thread) {}
29 ~SkiaCpuPipeline() {}
30
31 bool pinImages(std::vector<SkImage*>& mutableImages) override { return false; }
32 bool pinImages(LsaVector<sk_sp<Bitmap>>& images) override { return false; }
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;
40 void setHardwareBuffer(AHardwareBuffer* hardwareBuffer) override {}
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;
52 bool swapBuffers(const renderthread::Frame& frame, IRenderPipeline::DrawResult& drawResult,
53 const SkRect& screenDirty, FrameInfo* currentFrameInfo,
54 bool* requireSwap) override {
55 return false;
56 }
57 DeferredLayerUpdater* createTextureLayer() override { return nullptr; }
58 bool setSurface(ANativeWindow* surface, renderthread::SwapBehavior swapBehavior) override;
59 [[nodiscard]] android::base::unique_fd flush() override {
60 return android::base::unique_fd(-1);
61 };
62 void onStop() override {}
63 bool isSurfaceReady() override { return mSurface.get() != nullptr; }
64 bool isContextReady() override { return true; }
65
66 const SkM44& getPixelSnapMatrix() const override {
67 static const SkM44 sSnapMatrix = SkM44();
68 return sSnapMatrix;
69 }
70
71private:
72 sk_sp<SkSurface> mSurface;
73};
74
75} /* namespace skiapipeline */
76} /* namespace uirenderer */
77} /* namespace android */