1 /*
2  * Copyright 2022 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 <renderengine/ExternalTexture.h>
20 
21 namespace android {
22 namespace renderengine {
23 namespace mock {
24 
25 class FakeExternalTexture : public renderengine::ExternalTexture {
26     const sp<GraphicBuffer> mEmptyBuffer =
27             sp<GraphicBuffer>::make(1u, 1u, PIXEL_FORMAT_RGBA_8888,
28                                     GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_SW_READ_OFTEN);
29     uint32_t mWidth;
30     uint32_t mHeight;
31     uint64_t mId;
32     PixelFormat mPixelFormat;
33     uint64_t mUsage;
34 
35 public:
FakeExternalTexture(uint32_t width,uint32_t height,uint64_t id,PixelFormat pixelFormat,uint64_t usage)36     FakeExternalTexture(uint32_t width, uint32_t height, uint64_t id, PixelFormat pixelFormat,
37                         uint64_t usage)
38           : mWidth(width), mHeight(height), mId(id), mPixelFormat(pixelFormat), mUsage(usage) {}
getBuffer()39     const sp<GraphicBuffer>& getBuffer() const { return mEmptyBuffer; }
hasSameBuffer(const renderengine::ExternalTexture & other)40     bool hasSameBuffer(const renderengine::ExternalTexture& other) const override {
41         return getId() == other.getId();
42     }
getWidth()43     uint32_t getWidth() const override { return mWidth; }
getHeight()44     uint32_t getHeight() const override { return mHeight; }
getId()45     uint64_t getId() const override { return mId; }
getPixelFormat()46     PixelFormat getPixelFormat() const override { return mPixelFormat; }
getUsage()47     uint64_t getUsage() const override { return mUsage; }
remapBuffer()48     void remapBuffer() override {}
49     ~FakeExternalTexture() = default;
50 };
51 
52 } // namespace mock
53 } // namespace renderengine
54 } // namespace android
55