Markus Tavenrath | cb9609f | 2018-12-26 00:52:44 +0900 | [diff] [blame^] | 1 | // |
| 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 | |
| 22 | namespace gl |
| 23 | { |
| 24 | |
| 25 | ANGLE_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 | |
| 33 | ANGLE_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 | |
| 41 | ANGLE_INLINE angle::Result Context::syncDirtyObjects(const State::DirtyObjects &objectMask) |
| 42 | { |
| 43 | return mGLState.syncDirtyObjects(this, objectMask); |
| 44 | } |
| 45 | |
| 46 | ANGLE_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 | |
| 59 | ANGLE_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_ |