Comparing version 5.3.0-beta.67 to 5.3.0-beta.68
{ | ||
"name": "xterm", | ||
"description": "Full xterm terminal, in your browser", | ||
"version": "5.3.0-beta.67", | ||
"version": "5.3.0-beta.68", | ||
"main": "lib/xterm.js", | ||
@@ -6,0 +6,0 @@ "style": "css/xterm.css", |
@@ -154,46 +154,44 @@ /** | ||
// expensive relative to drawing the glyphs, so there is no need to wait for an idle callback. | ||
if (TextureAtlas.maxAtlasPages && this._pages.length >= Math.max(4, TextureAtlas.maxAtlasPages / 2)) { | ||
queueMicrotask(() => { | ||
// Find the set of the largest 4 images, below the maximum size, with the highest | ||
// percentages used | ||
const pagesBySize = this._pages.filter(e => { | ||
return e.canvas.width * 2 <= (TextureAtlas.maxTextureSize || Constants.FORCED_MAX_TEXTURE_SIZE); | ||
}).sort((a, b) => { | ||
if (b.canvas.width !== a.canvas.width) { | ||
return b.canvas.width - a.canvas.width; | ||
} | ||
return b.percentageUsed - a.percentageUsed; | ||
}); | ||
let sameSizeI = -1; | ||
let size = 0; | ||
for (let i = 0; i < pagesBySize.length; i++) { | ||
if (pagesBySize[i].canvas.width !== size) { | ||
sameSizeI = i; | ||
size = pagesBySize[i].canvas.width; | ||
} else if (i - sameSizeI === 3) { | ||
break; | ||
} | ||
if (TextureAtlas.maxAtlasPages && this._pages.length >= Math.max(4, TextureAtlas.maxAtlasPages)) { | ||
// Find the set of the largest 4 images, below the maximum size, with the highest | ||
// percentages used | ||
const pagesBySize = this._pages.filter(e => { | ||
return e.canvas.width * 2 <= (TextureAtlas.maxTextureSize || Constants.FORCED_MAX_TEXTURE_SIZE); | ||
}).sort((a, b) => { | ||
if (b.canvas.width !== a.canvas.width) { | ||
return b.canvas.width - a.canvas.width; | ||
} | ||
return b.percentageUsed - a.percentageUsed; | ||
}); | ||
let sameSizeI = -1; | ||
let size = 0; | ||
for (let i = 0; i < pagesBySize.length; i++) { | ||
if (pagesBySize[i].canvas.width !== size) { | ||
sameSizeI = i; | ||
size = pagesBySize[i].canvas.width; | ||
} else if (i - sameSizeI === 3) { | ||
break; | ||
} | ||
} | ||
// Gather details of the merge | ||
const mergingPages = pagesBySize.slice(sameSizeI, sameSizeI + 4); | ||
const sortedMergingPagesIndexes = mergingPages.map(e => e.glyphs[0].texturePage).sort((a, b) => a > b ? 1 : -1); | ||
const mergedPageIndex = sortedMergingPagesIndexes[0]; | ||
// Gather details of the merge | ||
const mergingPages = pagesBySize.slice(sameSizeI, sameSizeI + 4); | ||
const sortedMergingPagesIndexes = mergingPages.map(e => e.glyphs[0].texturePage).sort((a, b) => a > b ? 1 : -1); | ||
const mergedPageIndex = this.pages.length - mergingPages.length; | ||
// Merge into the new page | ||
const mergedPage = this._mergePages(mergingPages, mergedPageIndex); | ||
mergedPage.version++; | ||
// Merge into the new page | ||
const mergedPage = this._mergePages(mergingPages, mergedPageIndex); | ||
mergedPage.version++; | ||
// Replace the first _merging_ page with the _merged_ page | ||
this._pages[mergedPageIndex] = mergedPage; | ||
// Delete the pages, shifting glyph texture pages as needed | ||
for (let i = sortedMergingPagesIndexes.length - 1; i >= 0; i--) { | ||
this._deletePage(sortedMergingPagesIndexes[i]); | ||
} | ||
// Delete the other 3 pages, shifting glyph texture pages as needed | ||
for (let i = sortedMergingPagesIndexes.length - 1; i >= 1; i--) { | ||
this._deletePage(sortedMergingPagesIndexes[i]); | ||
} | ||
// Add the new merged page to the end | ||
this.pages.push(mergedPage); | ||
// Request the model to be cleared to refresh all texture pages. | ||
this._requestClearModel = true; | ||
this._onAddTextureAtlasCanvas.fire(mergedPage.canvas); | ||
}); | ||
// Request the model to be cleared to refresh all texture pages. | ||
this._requestClearModel = true; | ||
this._onAddTextureAtlasCanvas.fire(mergedPage.canvas); | ||
} | ||
@@ -760,3 +758,3 @@ | ||
// Create a new one if too much vertical space would be wasted or there is not enough room | ||
// Create a new page if too much vertical space would be wasted or there is not enough room | ||
// left in the page. The previous active row will become fixed in the process as it now has a | ||
@@ -767,3 +765,3 @@ // fixed height | ||
// current page | ||
let wasNewPageCreated = false; | ||
let wasPageAndRowFound = false; | ||
if (activePage.currentRow.y + activePage.currentRow.height + rasterizedGlyph.size.y >= activePage.canvas.height) { | ||
@@ -781,11 +779,26 @@ // Find the first page with room to create the new row on | ||
} else { | ||
// Create a new page if there is no room | ||
const newPage = this._createNewPage(); | ||
activePage = newPage; | ||
activeRow = newPage.currentRow; | ||
activeRow.height = rasterizedGlyph.size.y; | ||
wasNewPageCreated = true; | ||
// Before creating a new atlas page that would trigger a page merge, check if the | ||
// current active row is sufficient when ignoring the ROW_PIXEL_THRESHOLD. This will | ||
// improve texture utilization by using the available space before the page is merged | ||
// and becomes static. | ||
if ( | ||
TextureAtlas.maxAtlasPages && | ||
this._pages.length >= TextureAtlas.maxAtlasPages && | ||
activeRow.y + rasterizedGlyph.size.y <= activePage.canvas.height && | ||
activeRow.height >= rasterizedGlyph.size.y && | ||
activeRow.x + rasterizedGlyph.size.x <= activePage.canvas.width | ||
) { | ||
// activePage and activeRow is already valid | ||
wasPageAndRowFound = true; | ||
} else { | ||
// Create a new page if there is no room | ||
const newPage = this._createNewPage(); | ||
activePage = newPage; | ||
activeRow = newPage.currentRow; | ||
activeRow.height = rasterizedGlyph.size.y; | ||
wasPageAndRowFound = true; | ||
} | ||
} | ||
} | ||
if (!wasNewPageCreated) { | ||
if (!wasPageAndRowFound) { | ||
// Fix the current row as the new row is being added below | ||
@@ -792,0 +805,0 @@ if (activePage.currentRow.height > 0) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2343794
24445