Home | History | Annotate | Download | only in RenderEngine
      1 /*
      2  * Copyright (C) 2018 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 <gmock/gmock.h>
     20 
     21 #include "RenderEngine/Image.h"
     22 #include "RenderEngine/Mesh.h"
     23 #include "RenderEngine/RenderEngine.h"
     24 #include "RenderEngine/Surface.h"
     25 #include "RenderEngine/Texture.h"
     26 
     27 namespace android {
     28 namespace RE {
     29 namespace mock {
     30 
     31 class RenderEngine : public RE::RenderEngine {
     32 public:
     33     RenderEngine();
     34     ~RenderEngine() override;
     35 
     36     MOCK_METHOD0(createSurface, std::unique_ptr<RE::Surface>());
     37     MOCK_METHOD0(createImage, std::unique_ptr<RE::Image>());
     38     MOCK_CONST_METHOD0(primeCache, void());
     39     MOCK_METHOD1(dump, void(String8&));
     40     MOCK_CONST_METHOD0(supportsImageCrop, bool());
     41     MOCK_CONST_METHOD0(isCurrent, bool());
     42     MOCK_METHOD1(setCurrentSurface, bool(const RE::Surface&));
     43     MOCK_METHOD0(resetCurrentSurface, void());
     44     MOCK_METHOD0(flush, base::unique_fd());
     45     MOCK_METHOD0(finish, bool());
     46     MOCK_METHOD1(waitFence, bool(base::unique_fd*));
     47     bool waitFence(base::unique_fd fd) override { return waitFence(&fd); };
     48     MOCK_METHOD4(clearWithColor, void(float, float, float, float));
     49     MOCK_METHOD6(fillRegionWithColor, void(const Region&, uint32_t, float, float, float, float));
     50     MOCK_METHOD4(setScissor, void(uint32_t, uint32_t, uint32_t, uint32_t));
     51     MOCK_METHOD0(disableScissor, void());
     52     MOCK_METHOD2(genTextures, void(size_t, uint32_t*));
     53     MOCK_METHOD2(deleteTextures, void(size_t, uint32_t const*));
     54     MOCK_METHOD2(bindExternalTextureImage, void(uint32_t, const RE::Image&));
     55     MOCK_METHOD5(readPixels, void(size_t, size_t, size_t, size_t, uint32_t*));
     56     MOCK_CONST_METHOD0(checkErrors, void());
     57     MOCK_METHOD6(setViewportAndProjection,
     58                  void(size_t, size_t, Rect, size_t, bool, Transform::orientation_flags));
     59     MOCK_METHOD4(setupLayerBlending, void(bool, bool, bool, const half4&));
     60     MOCK_METHOD1(setupLayerTexturing, void(const Texture&));
     61     MOCK_METHOD0(setupLayerBlackedOut, void());
     62     MOCK_METHOD4(setupFillWithColor, void(float, float, float, float));
     63     MOCK_METHOD1(setupColorTransform, void(const mat4&));
     64     MOCK_METHOD1(setSaturationMatrix, void(const mat4&));
     65     MOCK_METHOD0(disableTexturing, void());
     66     MOCK_METHOD0(disableBlending, void());
     67     MOCK_METHOD1(setSourceY410BT2020, void(bool));
     68     MOCK_METHOD1(setSourceDataSpace, void(ui::Dataspace));
     69     MOCK_METHOD1(setOutputDataSpace, void(ui::Dataspace));
     70     MOCK_METHOD1(setDisplayMaxLuminance, void(const float));
     71     MOCK_METHOD2(bindNativeBufferAsFrameBuffer,
     72                  void(ANativeWindowBuffer*, RE::BindNativeBufferAsFramebuffer*));
     73     MOCK_METHOD1(unbindNativeBufferAsFrameBuffer, void(RE::BindNativeBufferAsFramebuffer*));
     74     MOCK_METHOD1(drawMesh, void(const Mesh&));
     75     MOCK_CONST_METHOD0(getMaxTextureSize, size_t());
     76     MOCK_CONST_METHOD0(getMaxViewportDims, size_t());
     77 };
     78 
     79 class Surface : public RE::Surface {
     80 public:
     81     Surface();
     82     ~Surface() override;
     83 
     84     MOCK_METHOD1(setCritical, void(bool));
     85     MOCK_METHOD1(setAsync, void(bool));
     86     MOCK_METHOD1(setNativeWindow, void(ANativeWindow*));
     87     MOCK_CONST_METHOD0(swapBuffers, void());
     88     MOCK_CONST_METHOD0(queryRedSize, int32_t());
     89     MOCK_CONST_METHOD0(queryGreenSize, int32_t());
     90     MOCK_CONST_METHOD0(queryBlueSize, int32_t());
     91     MOCK_CONST_METHOD0(queryAlphaSize, int32_t());
     92     MOCK_CONST_METHOD0(queryWidth, int32_t());
     93     MOCK_CONST_METHOD0(queryHeight, int32_t());
     94 };
     95 
     96 class Image : public RE::Image {
     97 public:
     98     Image();
     99     ~Image() override;
    100 
    101     MOCK_METHOD4(setNativeWindowBuffer,
    102                  bool(ANativeWindowBuffer* buffer, bool isProtected, int32_t cropWidth,
    103                       int32_t cropHeight));
    104 };
    105 
    106 } // namespace mock
    107 } // namespace RE
    108 } // namespace android
    109