blob: f7116e2d852d6da4bde169bc9a98fa18b9d03a97 [file] [log] [blame]
John Reck3b202512014-06-23 13:13:08 -07001/*
2 * Copyright (C) 2014 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 RENDERSTATE_H
17#define RENDERSTATE_H
18
19#include <GLES2/gl2.h>
20#include <GLES2/gl2ext.h>
21
22#include <private/hwui/DrawGlInfo.h>
23
24#include "Caches.h"
25#include "utils/Macros.h"
26
27namespace android {
28namespace uirenderer {
29
30namespace renderthread {
31class RenderThread;
32}
33
34// TODO: Replace Cache's GL state tracking with this. For now it's more a thin
35// wrapper of Caches for users to migrate to.
36class RenderState {
37 PREVENT_COPY_AND_ASSIGN(RenderState);
38public:
39 void onGLContextCreated();
40
41 void setViewport(GLsizei width, GLsizei height);
42 void getViewport(GLsizei* outWidth, GLsizei* outHeight);
43
44 void bindFramebuffer(GLuint fbo);
45 GLint getFramebuffer() { return mFramebuffer; }
46
47 void invokeFunctor(Functor* functor, DrawGlInfo::Mode mode, DrawGlInfo* info);
48
49 void debugOverdraw(bool enable, bool clear);
50
51private:
52 friend class renderthread::RenderThread;
53
54 void interruptForFunctorInvoke();
55 void resumeFromFunctorInvoke();
56
57 RenderState();
58 ~RenderState();
59
60 Caches* mCaches;
61
62 GLsizei mViewportWidth;
63 GLsizei mViewportHeight;
64 GLuint mFramebuffer;
65};
66
67} /* namespace uirenderer */
68} /* namespace android */
69
70#endif /* RENDERSTATE_H */