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

[WIP] 1404 Get Raster Pixel Color At Location #12116

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
pixel ratio
  • Loading branch information
Joe Beuckman committed Jul 26, 2022
commit c71b1047282032e0fa38c2702c97d862223124b9
16 changes: 5 additions & 11 deletions src/render/painter.js
Original file line number Diff line number Diff line change
@@ -721,17 +721,14 @@ class Painter {
colorForLayerPoint(layerId: string, point: PointLike) {

const layer = this.style._layers[layerId];
const sourceCache = this.style._getLayerSourceCache(layer);
if (layer.type !== 'raster') { return }

const layerIds = [layerId];
const sourceCache = this.style._getLayerSourceCache(layer);

sourceCache.prepare(this.context);

const coordsAscending: Array<OverscaledTileID> = sourceCache.getVisibleCoordinates();
const coordsDescending: Array<OverscaledTileID> = coordsAscending.slice().reverse();
const coordsDescendingSymbol: Array<OverscaledTileID> = sourceCache
.getVisibleCoordinates(true)
.reverse();

// Rebind the main framebuffer now that all offscreen layers have been rendered:
// this.context.bindFramebuffer.set(null);
@@ -747,14 +744,11 @@ class Painter {

this.renderPass = "translucent";


// For symbol layers in the translucent pass, we add extra tiles to the renderable set
// for cross-tile symbol fading. Symbol layers don't use tile clipping, so no need to render
// separate clipping masks
const coords = sourceCache
? (layer.type === "symbol"
? coordsDescendingSymbol
: coordsDescending)
? coordsDescending
: undefined;

this._renderTileClippingMasks(
@@ -767,8 +761,8 @@ class Painter {
const gl = this.context.gl;
var pixel = new Uint8Array(4);
gl.readPixels(
point.x,
this.height - point.y,
point.x * window.devicePixelRatio,
this.height - point.y * window.devicePixelRatio,
1,
1,
gl.RGBA,