diff --git a/blocks.js b/blocks.js index 9b2a8281..ee497ddf 100755 --- a/blocks.js +++ b/blocks.js @@ -150,7 +150,7 @@ CustomCommandBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2017-January-13'; +modules.blocks = '2017-April-10'; var SyntaxElementMorph; var BlockMorph; @@ -10918,11 +10918,17 @@ ColorSlotMorph.prototype.getUserColor = function () { pal.setPosition(this.bottomLeft().add(new Point(0, this.edge))); hand.processMouseMove = function (event) { + var clr = world.getGlobalPixelColor(hand.position()); hand.setPosition(new Point( event.pageX - posInDocument.x, event.pageY - posInDocument.y )); - myself.setColor(world.getGlobalPixelColor(hand.position())); + if (!clr.a) { + // ignore transparent, + // needed for retina-display support + return; + } + myself.setColor(clr); }; hand.processMouseDown = nop; diff --git a/gui.js b/gui.js index f63a950f..11ab5422 100644 --- a/gui.js +++ b/gui.js @@ -74,7 +74,7 @@ isRetinaSupported, SliderMorph, Animation*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2017-January-13'; +modules.gui = '2017-April-10'; // Declarations @@ -3187,7 +3187,7 @@ IDE_Morph.prototype.aboutSnap = function () { module, btn1, btn2, btn3, btn4, licenseBtn, translatorsBtn, world = this.world(); - aboutTxt = 'Snap! 4.0.10\nBuild Your Own Blocks\n\n' + aboutTxt = 'Snap! 4.0.10.1\nBuild Your Own Blocks\n\n' + 'Copyright \u24B8 2017 Jens M\u00F6nig and ' + 'Brian Harvey\n' + 'jens@moenig.org, bh@cs.berkeley.edu\n\n' diff --git a/history.txt b/history.txt index 78ae5ebd..168b7a79 100755 --- a/history.txt +++ b/history.txt @@ -3403,3 +3403,7 @@ Fixes: 170410 ------ * Revert to 4.0.10 to prepare for newly surfaced bug in the Chrome browser +* fixed #1707 (new Chrome blitting issue) + +== v4.0.10.1 - maintenance release - === + diff --git a/morphic.js b/morphic.js index 7d76747e..deb372e8 100755 --- a/morphic.js +++ b/morphic.js @@ -1137,7 +1137,7 @@ /*global window, HTMLCanvasElement, FileReader, Audio, FileList*/ -var morphicVersion = '2017-January-09'; +var morphicVersion = '2017-April-10'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -11294,29 +11294,13 @@ WorldMorph.prototype.fillPage = function () { // WorldMorph global pixel access: WorldMorph.prototype.getGlobalPixelColor = function (point) { + // answer the color at the given point. + /* - answer the color at the given point. + // original method, now deprecated as of 4/4/2017 because Chrome + // "taints" the on-screen canvas as soon as its image data is + // requested, significantly slowing down subsequent blittings - Note: for some strange reason this method works fine if the page is - opened via HTTP, but *not*, if it is opened from a local uri - (e.g. from a directory), in which case it's always null. - - This behavior is consistent throughout several browsers. I have no - clue what's behind this, apparently the imageData attribute of - canvas context only gets filled with meaningful data if transferred - via HTTP ??? - - This is somewhat of a showstopper for color detection in a planned - offline version of Snap. - - The issue has also been discussed at: (join lines before pasting) - http://stackoverflow.com/questions/4069400/ - canvas-getimagedata-doesnt-work-when-running-locally-on-windows- - security-excep - - The suggestion solution appears to work, since the settings are - applied globally. -*/ var dta = this.worldCanvas.getContext('2d').getImageData( point.x, point.y, @@ -11324,6 +11308,14 @@ WorldMorph.prototype.getGlobalPixelColor = function (point) { 1 ).data; return new Color(dta[0], dta[1], dta[2]); +*/ + + var clr = this.hand.morphAtPointer().getPixelColor(this.hand.position()); + // IMPORTANT: + // all callers of getGlobalPixelColor should make provisions for retina + // display support, which gets null-pixels interlaced with non-null ones: + // if (!clr.a) {/* ignore */ } + return clr; }; // WorldMorph events: diff --git a/paint.js b/paint.js index b116c105..067f41da 100644 --- a/paint.js +++ b/paint.js @@ -63,6 +63,8 @@ Jan 18 - avoid pixel collision detection in PaintCanvas (Jens) Mar 22 - fixed automatic rotation center point mechanism (Jens) May 10 - retina display support adjustments (Jens) + 2017 + April 10 - getGlobalPixelColor adjustment for Chrome & retina (Jens) */ /*global Point, Rectangle, DialogBoxMorph, AlignmentMorph, PushButtonMorph, @@ -73,7 +75,7 @@ StageMorph, isNil*/ // Global stuff //////////////////////////////////////////////////////// -modules.paint = '2016-July-14'; +modules.paint = '2017-April-10'; // Declarations @@ -461,6 +463,11 @@ PaintEditorMorph.prototype.getUserColor = function () { event.pageY - posInDocument.y )); color = world.getGlobalPixelColor(hand.position()); + if (!color.a) { + // ignore transparent, + // needed for retina-display support + return; + } color.a = 255; myself.propertiesControls.colorpicker.action(color); };