Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IconLayer: fix copy texture data when resize #4151

Merged
merged 3 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/layers/icon-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ The rotating angle of each object, in degrees.
- If a number is provided, it is used as the angle for all objects.
- If a function is provided, it is called on each object to retrieve its angle.


## Use binary attributes

This section is about the special requirements when [supplying attributes directly](/docs/developer-guide/performance.md#supply-attributes-directly) to an `IconLayer`.
Expand Down
7 changes: 5 additions & 2 deletions modules/layers/src/icon-layer/icon-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const noop = () => {};
const DEFAULT_TEXTURE_PARAMETERS = {
[GL.TEXTURE_MIN_FILTER]: GL.LINEAR_MIPMAP_LINEAR,
// GL.LINEAR is the default value but explicitly set it here
[GL.TEXTURE_MAG_FILTER]: GL.LINEAR
[GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
// for texture boundary artifact
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
};

function nextPowOfTwo(number) {
Expand Down Expand Up @@ -49,7 +52,7 @@ function resizeTexture(gl, texture, width, height) {

const newTexture = cloneTextureFrom(texture, {width, height});
copyToTexture(texture, newTexture, {
targetY: height - oldHeight,
targetY: 0,
width: oldWidth,
height: oldHeight
});
Expand Down
Binary file added test/render/golden-images/icon-lnglat-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/render/golden-images/icon-lnglat-resize-texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 33 additions & 33 deletions test/render/test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ export const TEST_CASES = [
viewState: {
latitude: 37.751537058389985,
longitude: -122.42694203247012,
zoom: 11.5,
zoom: 12,
pitch: 0,
bearing: 0
},
Expand All @@ -746,7 +746,10 @@ export const TEST_CASES = [
updateTriggers: {
getIcon: 1
},
sizeScale: 12,
sizeScale: 24,
opacity: 0.8,
pickable: true,
getSize: d => (d.RACKS > 2 ? 2 : 1),
getPosition: d => d.COORDINATES,
getColor: d => [64, 64, 72],
getIcon: d => {
Expand All @@ -758,19 +761,16 @@ export const TEST_CASES = [
return Object.assign({}, dataSamples.iconAtlas['marker-warning'], {
url: './test/render/icon-warning.png'
});
},
getSize: d => (d.RACKS > 2 ? 2 : 1),
opacity: 0.8,
pickable: true,
onAfterRender: ({layers, done}) => {
if (layers[0].state.iconManager.loaded) {
// data is loaded
done();
}
}
})
],
goldenImage: './test/render/golden-images/icon-lnglat.png'
onAfterRender: ({layers, done}) => {
if (layers[0].state.iconManager.loaded) {
// data is loaded
done();
}
},
goldenImage: './test/render/golden-images/icon-lnglat-large.png'
},
// This is based on last test case
// use the same layer id 'icon-lnglat-auto' as last test case to trigger the layer update and test texture resize logic
Expand All @@ -779,47 +779,47 @@ export const TEST_CASES = [
viewState: {
latitude: 37.751537058389985,
longitude: -122.42694203247012,
zoom: 11.5,
zoom: 12,
pitch: 0,
bearing: 0
},
layers: [
new IconLayer({
id: 'icon-lnglat-auto',
data: dataSamples.points,
opacity: 0.8,
updateTriggers: {
getIcon: 2
},
sizeScale: 12,
sizeScale: 24,
opacity: 0.8,
pickable: true,
getSize: d => (d.RACKS > 2 ? 2 : 1),
getPosition: d => d.COORDINATES,
getColor: d => [64, 64, 72],
getIcon: d => {
if (d.PLACEMENT === 'SW') {
return {
url: './test/render/golden-images/pointcloud-meter.png',
return Object.assign({}, dataSamples.iconAtlas.marker, {
url: './test/render/icon-marker.png',
id: 'marker-large',
width: 256,
height: 256,
anchorY: 256,
mask: false
};
height: 256
});
}
return {
url: './test/render/golden-images/h3-hexagon-flat.png',
return Object.assign({}, dataSamples.iconAtlas['marker-warning'], {
id: 'warning-large',
url: './test/render/icon-warning.png',
width: 1024,
height: 1024,
anchorY: 1024,
mask: false
};
},
onAfterRender: ({layers, done}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this why the test was failing? 😒

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

if (layers[0].state.iconManager.loaded) {
// data is loaded
done();
}
height: 1024
});
}
})
],
onAfterRender: ({layers, done}) => {
if (layers[0].state.iconManager.loaded) {
// data is loaded
done();
}
},
goldenImage: './test/render/golden-images/icon-lnglat-resize-texture.png'
},
{
Expand Down