fix framebuffer drawing on ios
This commit is contained in:
@@ -19,6 +19,7 @@ public:
|
||||
box cornersToBox(uint32_t z) const;
|
||||
|
||||
// Dimensions
|
||||
bool hasSize() const;
|
||||
uint16_t getWidth() const;
|
||||
uint16_t getHeight() const;
|
||||
uint16_t getFramebufferWidth() const;
|
||||
|
||||
@@ -103,6 +103,7 @@ public:
|
||||
void bindFramebuffer();
|
||||
void pushFramebuffer();
|
||||
GLuint popFramebuffer();
|
||||
void discardFramebuffers();
|
||||
void drawComposite(GLuint texture, const CompositeProperties &properties);
|
||||
|
||||
bool needsAnimation() const;
|
||||
|
||||
@@ -134,15 +134,17 @@ void Map::render(uv_async_t *async) {
|
||||
|
||||
map->prepare();
|
||||
|
||||
if (map->is_rendered.test_and_set() == false) {
|
||||
if (map->is_clean.test_and_set() == false) {
|
||||
map->render();
|
||||
map->is_swapped.clear();
|
||||
map->view.swap();
|
||||
} else {
|
||||
// We set the rendered flag in the test above, so we have to reset it
|
||||
// now that we're not actually rendering because the map is clean.
|
||||
map->is_rendered.clear();
|
||||
if (map->state.hasSize()) {
|
||||
if (map->is_rendered.test_and_set() == false) {
|
||||
if (map->is_clean.test_and_set() == false) {
|
||||
map->render();
|
||||
map->is_swapped.clear();
|
||||
map->view.swap();
|
||||
} else {
|
||||
// We set the rendered flag in the test above, so we have to reset it
|
||||
// now that we're not actually rendering because the map is clean.
|
||||
map->is_rendered.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,8 +558,6 @@ void Map::renderLayers(const std::vector<LayerDescription>& layers) {
|
||||
if (debug::renderTree) {
|
||||
std::cout << std::string(--indent * 4, ' ') << "}" << std::endl;
|
||||
}
|
||||
|
||||
glFlush();
|
||||
}
|
||||
|
||||
template <typename Styles>
|
||||
|
||||
@@ -59,6 +59,10 @@ box TransformState::cornersToBox(uint32_t z) const {
|
||||
|
||||
#pragma mark - Dimensions
|
||||
|
||||
bool TransformState::hasSize() const {
|
||||
return width && height;
|
||||
}
|
||||
|
||||
uint16_t TransformState::getWidth() const {
|
||||
return width;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ void Painter::drawComposite(GLuint texture, const CompositeProperties &propertie
|
||||
// Normally, we're using premultiplied alpha, but the resulting image we've
|
||||
// just drawn is non-premultiplied. That means when blending, we have to make
|
||||
// sure that we account for that.
|
||||
glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
useProgram(compositeShader->program);
|
||||
compositeShader->setMatrix(nativeMatrix);
|
||||
|
||||
@@ -7,7 +7,11 @@ using namespace llmr;
|
||||
|
||||
|
||||
void Painter::clearFramebuffers() {
|
||||
#ifdef TARGET_OS_IPHONE
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 1);
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
#endif
|
||||
|
||||
// Delete any framebuffers that we might have allocated
|
||||
glDeleteTextures((int)fbos_color.size(), fbos.data());
|
||||
@@ -24,10 +28,18 @@ void Painter::clearFramebuffers() {
|
||||
|
||||
void Painter::bindFramebuffer() {
|
||||
if (fbo_level < 0) {
|
||||
#ifdef TARGET_OS_IPHONE
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 1);
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
} else if (fbos.size() > (size_t)fbo_level) {
|
||||
#endif
|
||||
} else if (fbos.size() > (size_t) fbo_level) {
|
||||
GLuint fbo = fbos[fbo_level];
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
#if GL_EXT_discard_framebuffer
|
||||
const GLenum discards[] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
|
||||
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, discards);
|
||||
#endif
|
||||
} else {
|
||||
// TODO: Convert this to textures so we can composite them and use them in blend operations
|
||||
|
||||
|
||||
Reference in New Issue
Block a user