{"action":"created","comment":{"url":"https://api.github.com/repos/uber/deck.gl/pulls/comments/244051820","pull_request_review_id":187962914,"id":244051820,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDA1MTgyMA==","diff_hunk":"@@ -0,0 +1,186 @@\n+/* eslint-disable */\n+import GL from 'luma.gl/constants';\n+import {Texture2D, loadImages} from 'luma.gl';\n+\n+const MAX_CANVAS_WIDTH = 256;\n+const MAX_CANVAS_HEIGHT = 768;\n+\n+const DEFAULT_TEXTURE_MIN_FILTER = GL.LINEAR_MIPMAP_LINEAR;\n+// GL.LINEAR is the default value but explicitly set it here\n+const DEFAULT_TEXTURE_MAG_FILTER = GL.LINEAR;\n+\n+const noop = () => {};\n+\n+function nextPowOfTow(number) {\n+  return Math.pow(2, Math.ceil(Math.log(number) / Math.log(2)));\n+}\n+\n+function buildRowMapping(mapping, columns, yOffset) {\n+  for (let i = 0; i < columns.length; i++) {\n+    const {icon, xOffset} = columns[i];\n+    mapping[icon.url] = Object.assign({}, icon, {\n+      x: xOffset,\n+      y: yOffset\n+    });\n+  }\n+}\n+\n+function buildMapping({icons, maxCanvasWidth, maxCanvasHeight}) {\n+  let xOffset = 0;\n+  let yOffset = 0;\n+  let rowHeight = 0;\n+\n+  let columns = [];\n+  const mapping = {};\n+\n+  for (let i = 0; i < icons.length; i++) {\n+    const icon = icons[i];\n+    if (!mapping[icon.url]) {\n+      const {height, width} = icon;\n+\n+      // fill one row\n+      if (xOffset + width > maxCanvasWidth) {\n+        buildRowMapping(mapping, columns, yOffset);\n+\n+        xOffset = 0;\n+        yOffset = rowHeight + yOffset;\n+        rowHeight = 0;\n+        columns = [];\n+\n+        if (yOffset > maxCanvasHeight) {\n+          // TODO\n+        }\n+      }\n+\n+      columns.push({\n+        icon,\n+        xOffset\n+      });\n+\n+      xOffset = xOffset + width;\n+      rowHeight = Math.max(rowHeight, height);\n+    }\n+  }\n+\n+  if (columns.length > 0) {\n+    buildRowMapping(mapping, columns, yOffset);\n+  }\n+\n+  const canvasHeight = nextPowOfTow(rowHeight + yOffset);\n+  return {\n+    mapping,\n+    canvasHeight // yOffset + height of last row\n+  };\n+}\n+\n+export default class IconManager {\n+  constructor(\n+    gl,\n+    {\n+      data,\n+      getIcon,\n+      onTextureUpdate = noop,\n+      maxCanvasWidth = MAX_CANVAS_WIDTH,\n+      maxCanvasHeight = MAX_CANVAS_HEIGHT\n+    }\n+  ) {\n+    this.gl = gl;\n+    this.getIcon = getIcon;\n+    this.onTextureUpdate = onTextureUpdate;\n+    this.maxCanvasWidth = maxCanvasWidth;\n+    this.maxCanvasHeight = maxCanvasHeight;\n+\n+    // extract icons from data\n+    this._icons = this._getIcons(data);\n+    this._generateTexture();\n+  }\n+\n+  setData(data) {\n+    this.data = data;\n+    const nextIcons = this._getIcons(this.data);\n+    if (this._changed(this._icons, nextIcons)) {\n+      this._icons = nextIcons;","path":"modules/layers/src/icon-layer/icon-manager.js","position":102,"original_position":102,"commit_id":"aa52a4b625a9acf99c986a5f280ced1c967388ff","original_commit_id":"aa52a4b625a9acf99c986a5f280ced1c967388ff","user":{"login":"Pessimistress","id":2059298,"node_id":"MDQ6VXNlcjIwNTkyOTg=","avatar_url":"https://avatars2.githubusercontent.com/u/2059298?v=4","gravatar_id":"","url":"https://api.github.com/users/Pessimistress","html_url":"https://github.com/Pessimistress","followers_url":"https://api.github.com/users/Pessimistress/followers","following_url":"https://api.github.com/users/Pessimistress/following{/other_user}","gists_url":"https://api.github.com/users/Pessimistress/gists{/gist_id}","starred_url":"https://api.github.com/users/Pessimistress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pessimistress/subscriptions","organizations_url":"https://api.github.com/users/Pessimistress/orgs","repos_url":"https://api.github.com/users/Pessimistress/repos","events_url":"https://api.github.com/users/Pessimistress/events{/privacy}","received_events_url":"https://api.github.com/users/Pessimistress/received_events","type":"User","site_admin":false},"body":"Preferably we do not hold on to the intermediate icon definitions in memory.","created_at":"2018-12-26T21:34:56Z","updated_at":"2018-12-26T21:36:01Z","html_url":"https://github.com/uber/deck.gl/pull/2526#discussion_r244051820","pull_request_url":"https://api.github.com/repos/uber/deck.gl/pulls/2526","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/uber/deck.gl/pulls/comments/244051820"},"html":{"href":"https://github.com/uber/deck.gl/pull/2526#discussion_r244051820"},"pull_request":{"href":"https://api.github.com/repos/uber/deck.gl/pulls/2526"}}},"pull_request":{"url":"https://api.github.com/repos/uber/deck.gl/pulls/2526","id":240707931,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQwNzA3OTMx","html_url":"https://github.com/uber/deck.gl/pull/2526","diff_url":"https://github.com/uber/deck.gl/pull/2526.diff","patch_url":"https://github.com/uber/deck.gl/pull/2526.patch","issue_url":"https://api.github.com/repos/uber/deck.gl/issues/2526","number":2526,"state":"open","locked":false,"title":"support dynamically load icons","user":{"login":"xintongxia","id":2927808,"node_id":"MDQ6VXNlcjI5Mjc4MDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2927808?v=4","gravatar_id":"","url":"https://api.github.com/users/xintongxia","html_url":"https://github.com/xintongxia","followers_url":"https://api.github.com/users/xintongxia/followers","following_url":"https://api.github.com/users/xintongxia/following{/other_user}","gists_url":"https://api.github.com/users/xintongxia/gists{/gist_id}","starred_url":"https://api.github.com/users/xintongxia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xintongxia/subscriptions","organizations_url":"https://api.github.com/users/xintongxia/orgs","repos_url":"https://api.github.com/users/xintongxia/repos","events_url":"https://api.github.com/users/xintongxia/events{/privacy}","received_events_url":"https://api.github.com/users/xintongxia/received_events","type":"User","site_admin":false},"body":"#### Background\r\n[Issue](https://github.com/uber/deck.gl/issues/2484)\r\n\r\n#### Change List\r\n- add `IconManager` and update `IconLayer`\r\n- add test case for `IconManager`\r\n- add a simple example in layer browser\r\n","created_at":"2018-12-24T00:40:55Z","updated_at":"2018-12-26T21:36:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"72f2d9fa2fc2a78da097688cddd4dfdd87781669","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/uber/deck.gl/pulls/2526/commits","review_comments_url":"https://api.github.com/repos/uber/deck.gl/pulls/2526/comments","review_comment_url":"https://api.github.com/repos/uber/deck.gl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uber/deck.gl/issues/2526/comments","statuses_url":"https://api.github.com/repos/uber/deck.gl/statuses/aa52a4b625a9acf99c986a5f280ced1c967388ff","head":{"label":"uber:xx/dynamic-icons","ref":"xx/dynamic-icons","sha":"aa52a4b625a9acf99c986a5f280ced1c967388ff","user":{"login":"uber","id":538264,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUzODI2NA==","avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":48030204,"node_id":"MDEwOlJlcG9zaXRvcnk0ODAzMDIwNA==","name":"deck.gl","full_name":"uber/deck.gl","private":false,"owner":{"login":"uber","id":538264,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUzODI2NA==","avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/uber/deck.gl","description":"WebGL2 powered geospatial visualization layers","fork":false,"url":"https://api.github.com/repos/uber/deck.gl","forks_url":"https://api.github.com/repos/uber/deck.gl/forks","keys_url":"https://api.github.com/repos/uber/deck.gl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/deck.gl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/deck.gl/teams","hooks_url":"https://api.github.com/repos/uber/deck.gl/hooks","issue_events_url":"https://api.github.com/repos/uber/deck.gl/issues/events{/number}","events_url":"https://api.github.com/repos/uber/deck.gl/events","assignees_url":"https://api.github.com/repos/uber/deck.gl/assignees{/user}","branches_url":"https://api.github.com/repos/uber/deck.gl/branches{/branch}","tags_url":"https://api.github.com/repos/uber/deck.gl/tags","blobs_url":"https://api.github.com/repos/uber/deck.gl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/deck.gl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/deck.gl/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/deck.gl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/deck.gl/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/deck.gl/languages","stargazers_url":"https://api.github.com/repos/uber/deck.gl/stargazers","contributors_url":"https://api.github.com/repos/uber/deck.gl/contributors","subscribers_url":"https://api.github.com/repos/uber/deck.gl/subscribers","subscription_url":"https://api.github.com/repos/uber/deck.gl/subscription","commits_url":"https://api.github.com/repos/uber/deck.gl/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/deck.gl/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/deck.gl/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/deck.gl/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/deck.gl/contents/{+path}","compare_url":"https://api.github.com/repos/uber/deck.gl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/deck.gl/merges","archive_url":"https://api.github.com/repos/uber/deck.gl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/deck.gl/downloads","issues_url":"https://api.github.com/repos/uber/deck.gl/issues{/number}","pulls_url":"https://api.github.com/repos/uber/deck.gl/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/deck.gl/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/deck.gl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/deck.gl/labels{/name}","releases_url":"https://api.github.com/repos/uber/deck.gl/releases{/id}","deployments_url":"https://api.github.com/repos/uber/deck.gl/deployments","created_at":"2015-12-15T08:38:29Z","updated_at":"2018-12-26T15:27:05Z","pushed_at":"2018-12-26T20:53:35Z","git_url":"git://github.com/uber/deck.gl.git","ssh_url":"git@github.com:uber/deck.gl.git","clone_url":"https://github.com/uber/deck.gl.git","svn_url":"https://github.com/uber/deck.gl","homepage":"http://uber.github.io/deck.gl","size":139210,"stargazers_count":5456,"watchers_count":5456,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":787,"mirror_url":null,"archived":false,"open_issues_count":140,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":787,"open_issues":140,"watchers":5456,"default_branch":"master"}},"base":{"label":"uber:master","ref":"master","sha":"a889cebcd695e907bef0057a76bd141b94d7d1a3","user":{"login":"uber","id":538264,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUzODI2NA==","avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":48030204,"node_id":"MDEwOlJlcG9zaXRvcnk0ODAzMDIwNA==","name":"deck.gl","full_name":"uber/deck.gl","private":false,"owner":{"login":"uber","id":538264,"node_id":"MDEyOk9yZ2FuaXphdGlvbjUzODI2NA==","avatar_url":"https://avatars3.githubusercontent.com/u/538264?v=4","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/uber/deck.gl","description":"WebGL2 powered geospatial visualization layers","fork":false,"url":"https://api.github.com/repos/uber/deck.gl","forks_url":"https://api.github.com/repos/uber/deck.gl/forks","keys_url":"https://api.github.com/repos/uber/deck.gl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/deck.gl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/deck.gl/teams","hooks_url":"https://api.github.com/repos/uber/deck.gl/hooks","issue_events_url":"https://api.github.com/repos/uber/deck.gl/issues/events{/number}","events_url":"https://api.github.com/repos/uber/deck.gl/events","assignees_url":"https://api.github.com/repos/uber/deck.gl/assignees{/user}","branches_url":"https://api.github.com/repos/uber/deck.gl/branches{/branch}","tags_url":"https://api.github.com/repos/uber/deck.gl/tags","blobs_url":"https://api.github.com/repos/uber/deck.gl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/deck.gl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/deck.gl/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/deck.gl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/deck.gl/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/deck.gl/languages","stargazers_url":"https://api.github.com/repos/uber/deck.gl/stargazers","contributors_url":"https://api.github.com/repos/uber/deck.gl/contributors","subscribers_url":"https://api.github.com/repos/uber/deck.gl/subscribers","subscription_url":"https://api.github.com/repos/uber/deck.gl/subscription","commits_url":"https://api.github.com/repos/uber/deck.gl/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/deck.gl/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/deck.gl/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/deck.gl/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/deck.gl/contents/{+path}","compare_url":"https://api.github.com/repos/uber/deck.gl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/deck.gl/merges","archive_url":"https://api.github.com/repos/uber/deck.gl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/deck.gl/downloads","issues_url":"https://api.github.com/repos/uber/deck.gl/issues{/number}","pulls_url":"https://api.github.com/repos/uber/deck.gl/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/deck.gl/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/deck.gl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/deck.gl/labels{/name}","releases_url":"https://api.github.com/repos/uber/deck.gl/releases{/id}","deployments_url":"https://api.github.com/repos/uber/deck.gl/deployments","created_at":"2015-12-15T08:38:29Z","updated_at":"2018-12-26T15:27:05Z","pushed_at":"2018-12-26T20:53:35Z","git_url":"git://github.com/uber/deck.gl.git","ssh_url":"git@github.com:uber/deck.gl.git","clone_url":"https://github.com/uber/deck.gl.git","svn_url":"https://github.com/uber/deck.gl","homepage":"http://uber.github.io/deck.gl","size":139210,"stargazers_count":5456,"watchers_count":5456,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":787,"mirror_url":null,"archived":false,"open_issues_count":140,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":787,"open_issues":140,"watchers":5456,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uber/deck.gl/pulls/2526"},"html":{"href":"https://github.com/uber/deck.gl/pull/2526"},"issue":{"href":"https://api.github.com/repos/uber/deck.gl/issues/2526"},"comments":{"href":"https://api.github.com/repos/uber/deck.gl/issues/2526/comments"},"review_comments":{"href":"https://api.github.com/repos/uber/deck.gl/pulls/2526/comments"},"review_comment":{"href":"https://api.github.com/repos/uber/deck.gl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uber/deck.gl/pulls/2526/commits"},"statuses":{"href":"https://api.github.com/repos/uber/deck.gl/statuses/aa52a4b625a9acf99c986a5f280ced1c967388ff"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Pessimistress"}}