blob: adb31c08dd7f639422e3d185678ffb5941247f56 [file] [log] [blame]
Markus Tavenrathcb9609f2018-12-26 00:52:44 +09001//
2// Copyright (c) 2018 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// Context.inl.h: Defines inline functions of gl::Context class
8// Has to be included after libANGLE/Context.h when using one
9// of the defined functions
10
11#ifndef LIBANGLE_CONTEXT_INL_H_
12#define LIBANGLE_CONTEXT_INL_H_
13
14#include "libANGLE/GLES1Renderer.h"
15#include "libANGLE/renderer/ContextImpl.h"
16
17#define ANGLE_HANDLE_ERR(X) \
18 (void)(X); \
19 return;
20#define ANGLE_CONTEXT_TRY(EXPR) ANGLE_TRY_TEMPLATE(EXPR, ANGLE_HANDLE_ERR);
21
22namespace gl
23{
24
25ANGLE_INLINE angle::Result Context::syncDirtyBits()
26{
27 const State::DirtyBits &dirtyBits = mGLState.getDirtyBits();
28 ANGLE_TRY(mImplementation->syncState(this, dirtyBits, mAllDirtyBits));
29 mGLState.clearDirtyBits();
30 return angle::Result::Continue;
31}
32
33ANGLE_INLINE angle::Result Context::syncDirtyBits(const State::DirtyBits &bitMask)
34{
35 const State::DirtyBits &dirtyBits = (mGLState.getDirtyBits() & bitMask);
36 ANGLE_TRY(mImplementation->syncState(this, dirtyBits, bitMask));
37 mGLState.clearDirtyBits(dirtyBits);
38 return angle::Result::Continue;
39}
40
41ANGLE_INLINE angle::Result Context::syncDirtyObjects(const State::DirtyObjects &objectMask)
42{
43 return mGLState.syncDirtyObjects(this, objectMask);
44}
45
46ANGLE_INLINE angle::Result Context::prepareForDraw(PrimitiveMode mode)
47{
48 if (mGLES1Renderer)
49 {
50 ANGLE_TRY(mGLES1Renderer->prepareForDraw(mode, this, &mGLState));
51 }
52
53 ANGLE_TRY(syncDirtyObjects(mDrawDirtyObjects));
54 ASSERT(!isRobustResourceInitEnabled() ||
55 !mGLState.getDrawFramebuffer()->hasResourceThatNeedsInit());
56 return syncDirtyBits();
57}
58
59ANGLE_INLINE void Context::drawElements(PrimitiveMode mode,
60 GLsizei count,
61 DrawElementsType type,
62 const void *indices)
63{
64 // No-op if count draws no primitives for given mode
65 if (noopDraw(mode, count))
66 {
67 return;
68 }
69
70 ANGLE_CONTEXT_TRY(prepareForDraw(mode));
71 ANGLE_CONTEXT_TRY(mImplementation->drawElements(this, mode, count, type, indices));
72}
73
74} // namespace gl
75
76#endif // LIBANGLE_CONTEXT_INL_H_