Skip to content

Commit cb59f72

Browse files
committed
🔖 version 0.6.36, closes #225
1 parent 892c2e5 commit cb59f72

File tree

10 files changed

+78
-112
lines changed

10 files changed

+78
-112
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Version 0.6.36
2+
3+
* [[#225](https://github.com/bitbrain/braingdx/issues/225)] fix wrong insertion order of render layers
4+
* remove `ParticleEffectLoader` since it [now comes with libgdx](https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/assets/loaders/ParticleEffectLoader.html)
5+
16
# Version 0.6.35
27

38
* fix various bugs

Diff for: core/src/main/java/de/bitbrain/braingdx/assets/loader/ParticleLoader.java

-57
This file was deleted.

Diff for: core/src/main/java/de/bitbrain/braingdx/graphics/pipeline/CombinedRenderPipe.java

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public boolean hasEffects() {
7070
return batchPostProcessor.hasEffects();
7171
}
7272

73+
@Override
74+
public RenderLayer<?> getLayer() {
75+
return layer;
76+
}
77+
7378
@Override
7479
public void beforeRender() {
7580
layer.beforeRender();

Diff for: core/src/main/java/de/bitbrain/braingdx/graphics/pipeline/CombinedRenderPipeline.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* @author Miguel Gonzalez Sanchez
4646
* @version 1.0.0
4747
*/
48-
public class CombinedRenderPipeline implements RenderPipeline {
48+
public class CombinedRenderPipeline implements InternalRenderPipeline {
4949

5050
private static final boolean isDesktop = (Gdx.app.getType() == Application.ApplicationType.Desktop);
5151

@@ -156,7 +156,7 @@ public void putBefore(String existing, String id, RenderLayer layer, PostProcess
156156
Gdx.app.error("FATAL", "Unable add layer '" + id + "'!");
157157
return;
158158
}
159-
orderedPipes.put(index > 0 ? index - 1 : index, id, new CombinedRenderPipe(layer, processor, internalBatch, batchResolverMap, effects));
159+
orderedPipes.put(index, id, new CombinedRenderPipe(layer, processor, internalBatch, batchResolverMap, effects));
160160
this.hasEffects = hasEffects || effects.length > 0;
161161
pipes.clear();
162162
pipes.addAll(orderedPipes.valueList());
@@ -171,7 +171,7 @@ public void remove(String existingSourceId) {
171171
}
172172
orderedPipes.remove(existingSourceId);
173173
for (Object o : orderedPipes.valueList()) {
174-
CombinedRenderPipe pipe = (CombinedRenderPipe)o;
174+
CombinedRenderPipe pipe = (CombinedRenderPipe) o;
175175
if (pipe.hasEffects()) {
176176
return;
177177
}
@@ -247,6 +247,11 @@ public Collection<String> getPipeIds() {
247247
return orderedPipes.keySet();
248248
}
249249

250+
@Override
251+
public Collection<RenderPipe> getPipes() {
252+
return new ArrayList<RenderPipe>(pipes);
253+
}
254+
250255
@SuppressWarnings("unchecked")
251256
@Override
252257
public void render(float delta) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright 2017 Miguel Gonzalez Sanchez
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package de.bitbrain.braingdx.graphics.pipeline;
16+
17+
import java.util.Collection;
18+
19+
/**
20+
* Handles the complete pipeline of rendering internally. The pipeline consists of render pipes.
21+
*
22+
* @author Miguel Gonzalez Sanchez
23+
* @version 1.0.0
24+
*/
25+
public interface InternalRenderPipeline extends RenderPipeline {
26+
27+
Collection<String> getPipeIds();
28+
29+
Collection<RenderPipe> getPipes();
30+
}

Diff for: core/src/main/java/de/bitbrain/braingdx/graphics/pipeline/RenderPipe.java

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
public interface RenderPipe {
2727

28+
RenderLayer getLayer();
29+
2830
void beforeRender();
2931

3032
void render(float delta, FrameBuffer buffer);

Diff for: core/src/main/java/de/bitbrain/braingdx/graphics/pipeline/RenderPipeline.java

-7
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,5 @@ public interface RenderPipeline extends Disposable, Resizeable {
9696
*/
9797
void addEffects(String existingSourceId, PostProcessorEffect... effects);
9898

99-
/**
100-
* Returns an ordered collection of all registered layers
101-
*
102-
* @return an ordered collection of Strings
103-
*/
104-
Collection<String> getPipeIds();
105-
10699
void render(float delta);
107100
}

Diff for: core/src/test/java/de/bitbrain/braingdx/assets/loader/ParticleLoaderTest.java

-39
This file was deleted.

Diff for: core/src/test/java/de/bitbrain/braingdx/graphics/pipeline/MockedCombinedRenderPipelineFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class MockedCombinedRenderPipelineFactory implements RenderPipelineFactory {
1717

1818
@Override
19-
public RenderPipeline create() {
19+
public InternalRenderPipeline create() {
2020
ShaderConfig config = mock(ShaderConfig.class);
2121
PostProcessor processorMock = mock(PostProcessor.class);
2222
FrameBufferFactory factory = mock(FrameBufferFactory.class);

Diff for: core/src/test/java/de/bitbrain/braingdx/graphics/pipeline/RenderPipelineTest.java

+27-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.badlogic.gdx.Gdx;
55
import com.badlogic.gdx.graphics.GL20;
66
import de.bitbrain.braingdx.util.GdxUtils;
7+
import org.assertj.core.api.iterable.Extractor;
78
import org.junit.Before;
89
import org.junit.Test;
910
import org.junit.runner.RunWith;
@@ -28,17 +29,17 @@
2829
public class RenderPipelineTest {
2930

3031
@Parameter
31-
public RenderPipelineFactory pipelineFactory;
32+
public MockedCombinedRenderPipelineFactory pipelineFactory;
3233

33-
private RenderPipeline pipeline;
34+
private InternalRenderPipeline pipeline;
3435

3536
@Parameters
36-
public static Collection<RenderPipelineFactory[]> getParams() {
37-
List<RenderPipelineFactory[]> params = new ArrayList<RenderPipelineFactory[]>();
37+
public static Collection<MockedCombinedRenderPipelineFactory[]> getParams() {
38+
List<MockedCombinedRenderPipelineFactory[]> params = new ArrayList<MockedCombinedRenderPipelineFactory[]>();
3839
GdxUtils.mockApplicationContext();
3940
Gdx.gl = mock(GL20.class);
4041
when(Gdx.app.getType()).thenReturn(ApplicationType.Desktop);
41-
params.add(new RenderPipelineFactory[]{new MockedCombinedRenderPipelineFactory()});
42+
params.add(new MockedCombinedRenderPipelineFactory[]{new MockedCombinedRenderPipelineFactory()});
4243
return params;
4344
}
4445

@@ -155,4 +156,25 @@ public void testRemove_Existing() {
155156
assertThat(pipeline.getPipeIds()).containsExactly("c");
156157
}
157158

159+
@Test
160+
public void testReplace_Existing() {
161+
RenderLayer<?> expectedLayerA = mock(RenderLayer.class);
162+
RenderLayer<?> expectedLayerB = mock(RenderLayer.class);
163+
RenderLayer<?> expectedLayerC = mock(RenderLayer.class);
164+
RenderLayer<?> expectedLayerD = mock(RenderLayer.class);
165+
RenderLayer<?> expectedLayerANew = mock(RenderLayer.class);
166+
pipeline.put("a", expectedLayerA);
167+
pipeline.put("b", expectedLayerB);
168+
pipeline.putAfter("a", "c", expectedLayerC);
169+
pipeline.put("a", expectedLayerANew);
170+
pipeline.putBefore("c", "d", expectedLayerD);
171+
assertThat(pipeline.getPipeIds()).containsExactly("a", "d", "c", "b");
172+
assertThat(pipeline.getPipes()).extracting(new Extractor<RenderPipe, RenderLayer<?>>() {
173+
@Override
174+
public RenderLayer<?> extract(RenderPipe input) {
175+
return input.getLayer();
176+
}
177+
}).containsExactly(expectedLayerANew, expectedLayerD, expectedLayerC, expectedLayerB);
178+
}
179+
158180
}

0 commit comments

Comments
 (0)