GLES20RenderEngine.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright 2013 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. #ifndef SF_GLES20RENDERENGINE_H_
  17. #define SF_GLES20RENDERENGINE_H_
  18. #include <stdint.h>
  19. #include <sys/types.h>
  20. #include <GLES2/gl2.h>
  21. #include <Transform.h>
  22. #include "RenderEngine.h"
  23. #include "ProgramCache.h"
  24. #include "Description.h"
  25. // ---------------------------------------------------------------------------
  26. namespace android {
  27. // ---------------------------------------------------------------------------
  28. class String8;
  29. class Mesh;
  30. class Texture;
  31. class GLES20RenderEngine : public RenderEngine {
  32. GLuint mProtectedTexName;
  33. GLint mMaxViewportDims[2];
  34. GLint mMaxTextureSize;
  35. GLuint mVpWidth;
  36. GLuint mVpHeight;
  37. Rect mProjectionSourceCrop;
  38. bool mProjectionYSwap;
  39. Transform::orientation_flags mProjectionRotation;
  40. struct Group {
  41. GLuint texture;
  42. GLuint fbo;
  43. GLuint width;
  44. GLuint height;
  45. mat4 colorTransform;
  46. };
  47. Description mState;
  48. Vector<Group> mGroupStack;
  49. virtual void bindImageAsFramebuffer(EGLImageKHR image,
  50. uint32_t* texName, uint32_t* fbName, uint32_t* status,
  51. bool useReadPixels, int reqWidth, int reqHeight);
  52. virtual void unbindFramebuffer(uint32_t texName, uint32_t fbName, bool useReadPixels);
  53. public:
  54. GLES20RenderEngine();
  55. protected:
  56. virtual ~GLES20RenderEngine();
  57. virtual void dump(String8& result);
  58. virtual void setViewportAndProjection(size_t vpw, size_t vph,
  59. Rect sourceCrop, size_t hwh, bool yswap, Transform::orientation_flags rotation);
  60. virtual void setupLayerBlending(bool premultipliedAlpha, bool opaque, int alpha);
  61. virtual void setupDimLayerBlending(int alpha);
  62. virtual void setupLayerTexturing(const Texture& texture);
  63. virtual void setupLayerBlackedOut();
  64. virtual void setupFillWithColor(float r, float g, float b, float a);
  65. virtual mat4 setupColorTransform(const mat4& colorTransform);
  66. virtual void disableTexturing();
  67. virtual void disableBlending();
  68. virtual void setupLayerMasking(const Texture& maskTexture, float alphaThreshold);
  69. virtual void disableLayerMasking();
  70. virtual void drawMesh(const Mesh& mesh);
  71. virtual size_t getMaxTextureSize() const;
  72. virtual size_t getMaxViewportDims() const;
  73. virtual bool getProjectionYSwap() { return mProjectionYSwap; }
  74. virtual size_t getViewportWidth() const { return mVpWidth; }
  75. virtual size_t getViewportHeight() const { return mVpHeight; }
  76. virtual Rect getProjectionSourceCrop() const { return mProjectionSourceCrop; }
  77. virtual Transform::orientation_flags getProjectionRotation() const { return mProjectionRotation; }
  78. };
  79. // ---------------------------------------------------------------------------
  80. }; // namespace android
  81. // ---------------------------------------------------------------------------
  82. #endif /* SF_GLES20RENDERENGINE_H_ */