2013-06-07 22:35:48 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SF_RENDERENGINE_H_
|
|
|
|
#define SF_RENDERENGINE_H_
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <EGL/egl.h>
|
2013-08-08 04:24:32 +00:00
|
|
|
#include <EGL/eglext.h>
|
2013-09-02 04:36:12 +00:00
|
|
|
#include <ui/mat4.h>
|
2014-09-04 23:20:31 +00:00
|
|
|
#include <Transform.h>
|
2013-06-07 22:35:48 +00:00
|
|
|
|
2013-12-24 05:02:15 +00:00
|
|
|
#define EGL_NO_CONFIG ((EGLConfig)0)
|
|
|
|
|
2013-06-07 22:35:48 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
namespace android {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class String8;
|
2013-08-08 04:24:32 +00:00
|
|
|
class Rect;
|
|
|
|
class Region;
|
|
|
|
class Mesh;
|
2013-08-15 01:20:17 +00:00
|
|
|
class Texture;
|
2013-06-07 22:35:48 +00:00
|
|
|
|
|
|
|
class RenderEngine {
|
|
|
|
enum GlesVersion {
|
|
|
|
GLES_VERSION_1_0 = 0x10000,
|
|
|
|
GLES_VERSION_1_1 = 0x10001,
|
|
|
|
GLES_VERSION_2_0 = 0x20000,
|
|
|
|
GLES_VERSION_3_0 = 0x30000,
|
|
|
|
};
|
|
|
|
static GlesVersion parseGlesVersion(const char* str);
|
|
|
|
|
2013-12-24 04:44:38 +00:00
|
|
|
EGLConfig mEGLConfig;
|
2013-06-07 22:35:48 +00:00
|
|
|
EGLContext mEGLContext;
|
2013-12-24 04:44:38 +00:00
|
|
|
void setEGLHandles(EGLConfig config, EGLContext ctxt);
|
2013-06-07 22:35:48 +00:00
|
|
|
|
2013-08-15 21:56:51 +00:00
|
|
|
virtual void bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName, uint32_t* status) = 0;
|
|
|
|
virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName) = 0;
|
|
|
|
|
2013-06-07 22:35:48 +00:00
|
|
|
protected:
|
|
|
|
RenderEngine();
|
|
|
|
virtual ~RenderEngine() = 0;
|
|
|
|
|
|
|
|
public:
|
2013-12-24 04:44:38 +00:00
|
|
|
static RenderEngine* create(EGLDisplay display, int hwcFormat);
|
|
|
|
|
|
|
|
static EGLConfig chooseEglConfig(EGLDisplay display, int format);
|
2013-06-07 22:35:48 +00:00
|
|
|
|
2013-08-15 21:56:51 +00:00
|
|
|
// dump the extension strings. always call the base class.
|
|
|
|
virtual void dump(String8& result);
|
|
|
|
|
2013-08-08 04:24:32 +00:00
|
|
|
// helpers
|
2014-10-23 23:17:04 +00:00
|
|
|
void flush();
|
2013-08-08 04:24:32 +00:00
|
|
|
void clearWithColor(float red, float green, float blue, float alpha);
|
|
|
|
void fillRegionWithColor(const Region& region, uint32_t height,
|
|
|
|
float red, float green, float blue, float alpha);
|
|
|
|
|
|
|
|
// common to all GL versions
|
|
|
|
void setScissor(uint32_t left, uint32_t bottom, uint32_t right, uint32_t top);
|
|
|
|
void disableScissor();
|
|
|
|
void genTextures(size_t count, uint32_t* names);
|
|
|
|
void deleteTextures(size_t count, uint32_t const* names);
|
2013-09-20 00:08:37 +00:00
|
|
|
void readPixels(size_t l, size_t b, size_t w, size_t h, uint32_t* pixels);
|
2013-08-08 04:24:32 +00:00
|
|
|
|
|
|
|
class BindImageAsFramebuffer {
|
|
|
|
RenderEngine& mEngine;
|
2013-08-15 21:56:51 +00:00
|
|
|
uint32_t mTexName, mFbName;
|
|
|
|
uint32_t mStatus;
|
2013-08-08 04:24:32 +00:00
|
|
|
public:
|
|
|
|
BindImageAsFramebuffer(RenderEngine& engine, EGLImageKHR image);
|
|
|
|
~BindImageAsFramebuffer();
|
|
|
|
int getStatus() const;
|
|
|
|
};
|
2013-06-07 22:35:48 +00:00
|
|
|
|
2013-08-08 04:24:32 +00:00
|
|
|
// set-up
|
|
|
|
virtual void checkErrors() const;
|
2014-05-22 22:59:05 +00:00
|
|
|
virtual void setViewportAndProjection(size_t vpw, size_t vph,
|
2014-09-04 23:20:31 +00:00
|
|
|
Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation) = 0;
|
2013-06-07 22:35:48 +00:00
|
|
|
virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha) = 0;
|
|
|
|
virtual void setupDimLayerBlending(int alpha) = 0;
|
2013-08-15 01:20:17 +00:00
|
|
|
virtual void setupLayerTexturing(const Texture& texture) = 0;
|
2013-06-07 22:35:48 +00:00
|
|
|
virtual void setupLayerBlackedOut() = 0;
|
2013-08-29 01:13:56 +00:00
|
|
|
virtual void setupFillWithColor(float r, float g, float b, float a) = 0;
|
2013-06-07 22:35:48 +00:00
|
|
|
|
2014-10-20 22:46:09 +00:00
|
|
|
virtual mat4 setupColorTransform(const mat4& /* colorTransform */) {
|
|
|
|
return mat4();
|
|
|
|
}
|
|
|
|
|
2013-06-07 22:35:48 +00:00
|
|
|
virtual void disableTexturing() = 0;
|
|
|
|
virtual void disableBlending() = 0;
|
|
|
|
|
2013-08-08 04:24:32 +00:00
|
|
|
// drawing
|
|
|
|
virtual void drawMesh(const Mesh& mesh) = 0;
|
2013-06-07 22:35:48 +00:00
|
|
|
|
2013-08-08 04:24:32 +00:00
|
|
|
// queries
|
2013-06-07 22:35:48 +00:00
|
|
|
virtual size_t getMaxTextureSize() const = 0;
|
|
|
|
virtual size_t getMaxViewportDims() const = 0;
|
|
|
|
|
2013-12-24 04:44:38 +00:00
|
|
|
EGLConfig getEGLConfig() const;
|
2013-06-07 22:35:48 +00:00
|
|
|
EGLContext getEGLContext() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
}; // namespace android
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif /* SF_RENDERENGINE_H_ */
|