• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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> mNullBuffer = nullptr;
27     uint32_t mWidth;
28     uint32_t mHeight;
29     uint64_t mId;
30     PixelFormat mPixelFormat;
31     uint64_t mUsage;
32 
33 public:
FakeExternalTexture(uint32_t width,uint32_t height,uint64_t id,PixelFormat pixelFormat,uint64_t usage)34     FakeExternalTexture(uint32_t width, uint32_t height, uint64_t id, PixelFormat pixelFormat,
35                         uint64_t usage)
36           : mWidth(width), mHeight(height), mId(id), mPixelFormat(pixelFormat), mUsage(usage) {}
getBuffer()37     const sp<GraphicBuffer>& getBuffer() const { return mNullBuffer; }
hasSameBuffer(const renderengine::ExternalTexture & other)38     bool hasSameBuffer(const renderengine::ExternalTexture& other) const override {
39         return getId() == other.getId();
40     }
getWidth()41     uint32_t getWidth() const override { return mWidth; }
getHeight()42     uint32_t getHeight() const override { return mHeight; }
getId()43     uint64_t getId() const override { return mId; }
getPixelFormat()44     PixelFormat getPixelFormat() const override { return mPixelFormat; }
getUsage()45     uint64_t getUsage() const override { return mUsage; }
46     ~FakeExternalTexture() = default;
47 };
48 
49 } // namespace mock
50 } // namespace renderengine
51 } // namespace android
52