diff --git a/src/cursor-component.coffee b/src/cursor-component.coffee index 2bd7880a9..b0aed6dd0 100644 --- a/src/cursor-component.coffee +++ b/src/cursor-component.coffee @@ -7,14 +7,23 @@ CursorComponent = React.createClass displayName: 'CursorComponent' render: -> - {pixelRect, scrollTop, scrollLeft, defaultCharWidth} = @props - {top, left, height, width} = pixelRect - top -= scrollTop - left -= scrollLeft + {pixelRect, defaultCharWidth} = @props + {height, width} = pixelRect width = defaultCharWidth if width is 0 - WebkitTransform = "translate3d(#{left}px, #{top}px, 0px)" + WebkitTransform = @getTransform() div className: 'cursor', style: {height, width, WebkitTransform} + getTransform: -> + {pixelRect, scrollTop, scrollLeft, gpuDisabled} = @props + {top, left} = pixelRect + top -= scrollTop + left -= scrollLeft + + if gpuDisabled + "translate(#{left}px, #{top}px)" + else + "translate3d(#{left}px, #{top}px, 0px)" + shouldComponentUpdate: (newProps) -> not isEqualForProperties(newProps, @props, 'pixelRect', 'scrollTop', 'scrollLeft', 'defaultCharWidth') diff --git a/src/cursors-component.coffee b/src/cursors-component.coffee index a1e541bfb..6fd179cd9 100644 --- a/src/cursors-component.coffee +++ b/src/cursors-component.coffee @@ -12,7 +12,7 @@ CursorsComponent = React.createClass cursorBlinkIntervalHandle: null render: -> - {cursorPixelRects, scrollTop, scrollLeft, defaultCharWidth} = @props + {cursorPixelRects, scrollTop, scrollLeft, defaultCharWidth, gpuDisabled} = @props {blinkOff} = @state className = 'cursors' @@ -34,7 +34,7 @@ CursorsComponent = React.createClass shouldComponentUpdate: (newProps, newState) -> not newState.blinkOff is @state.blinkOff or - not isEqualForProperties(newProps, @props, 'cursorPixelRects', 'scrollTop', 'scrollLeft', 'defaultCharWidth') + not isEqualForProperties(newProps, @props, 'cursorPixelRects', 'scrollTop', 'scrollLeft', 'defaultCharWidth', 'gpuDisabled') componentWillUpdate: (newProps) -> cursorsMoved = @props.cursorPixelRects? and diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 8e1efdd3e..b146795b2 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -74,7 +74,7 @@ EditorComponent = React.createClass verticallyScrollable = editor.verticallyScrollable() horizontallyScrollable = editor.horizontallyScrollable() hiddenInputStyle = @getHiddenInputPosition() - hiddenInputStyle.WebkitTransform = 'translateZ(0)' + hiddenInputStyle.WebkitTransform = 'translateZ(0)' unless @gpuDisabled if @mouseWheelScreenRow? and not (renderedStartRow <= @mouseWheelScreenRow < renderedEndRow) mouseWheelScreenRow = @mouseWheelScreenRow @@ -87,7 +87,7 @@ EditorComponent = React.createClass GutterComponent { ref: 'gutter', onMouseDown: @onGutterMouseDown, onWidthChanged: @onGutterWidthChanged, lineDecorations, defaultCharWidth, editor, renderedRowRange, maxLineNumberDigits, scrollViewHeight, - scrollTop, scrollHeight, lineHeightInPixels, @pendingChanges, mouseWheelScreenRow + scrollTop, scrollHeight, lineHeightInPixels, @pendingChanges, mouseWheelScreenRow, @gpuDisabled } div ref: 'scrollView', className: 'scroll-view', onMouseDown: @onMouseDown, @@ -100,14 +100,14 @@ EditorComponent = React.createClass CursorsComponent { scrollTop, scrollLeft, cursorPixelRects, cursorBlinkPeriod, cursorBlinkResumeDelay, - lineHeightInPixels, defaultCharWidth, @scopedCharacterWidthsChangeCount + lineHeightInPixels, defaultCharWidth, @scopedCharacterWidthsChangeCount, @gpuDisabled } LinesComponent { ref: 'lines', editor, lineHeightInPixels, defaultCharWidth, lineDecorations, highlightDecorations, showIndentGuide, renderedRowRange, @pendingChanges, scrollTop, scrollLeft, @scrollingVertically, scrollHeight, scrollWidth, mouseWheelScreenRow, invisibles, - visible, scrollViewHeight, @scopedCharacterWidthsChangeCount, lineWidth + visible, scrollViewHeight, @scopedCharacterWidthsChangeCount, lineWidth, @gpuDisabled } ScrollbarComponent @@ -481,6 +481,7 @@ EditorComponent = React.createClass @subscribe atom.config.observe 'editor.showInvisibles', @setShowInvisibles @subscribe atom.config.observe 'editor.showLineNumbers', @setShowLineNumbers @subscribe atom.config.observe 'editor.scrollSensitivity', @setScrollSensitivity + @subscribe atom.config.observe 'editor.gpuDisabled', @setGPUDisabled onFocus: -> @refs.input.focus() @@ -873,6 +874,11 @@ EditorComponent = React.createClass if scrollSensitivity = parseInt(scrollSensitivity) @scrollSensitivity = Math.abs(scrollSensitivity) / 100 + setGPUDisabled: (gpuDisabled) -> + unless @gpuDisabled is gpuDisabled + @gpuDisabled = gpuDisabled + @requestUpdate() + screenPositionForMouseEvent: (event) -> pixelPosition = @pixelPositionForMouseEvent(event) @props.editor.screenPositionForPixelPosition(pixelPosition) diff --git a/src/editor-view.coffee b/src/editor-view.coffee index a7b200a7b..0c4ded5c6 100644 --- a/src/editor-view.coffee +++ b/src/editor-view.coffee @@ -57,6 +57,7 @@ class EditorView extends View softTabs: true softWrapAtPreferredLineLength: false scrollSensitivity: 40 + gpuDisabled: false @nextEditorId: 1 diff --git a/src/gutter-component.coffee b/src/gutter-component.coffee index 2555c7ebd..8ad08877e 100644 --- a/src/gutter-component.coffee +++ b/src/gutter-component.coffee @@ -15,14 +15,22 @@ GutterComponent = React.createClass measuredWidth: null render: -> - {scrollHeight, scrollViewHeight, scrollTop, onMouseDown} = @props + {scrollHeight, scrollViewHeight, onMouseDown} = @props div className: 'gutter', onClick: @onClick, onMouseDown: onMouseDown, # The line-numbers div must have the 'editor-colors' class so it has an # opaque background to avoid sub-pixel anti-aliasing problems on the GPU div className: 'gutter line-numbers editor-colors', ref: 'lineNumbers', style: height: Math.max(scrollHeight, scrollViewHeight) - WebkitTransform: "translate3d(0px, #{-scrollTop}px, 0px)" + WebkitTransform: @getTransform() + + getTransform: -> + {scrollTop, gpuDisabled} = @props + + if gpuDisabled + "translate(0px, #{-scrollTop}px)" + else + "translate3d(0px, #{-scrollTop}px, 0px)" componentWillMount: -> @lineNumberNodesById = {} @@ -39,7 +47,7 @@ GutterComponent = React.createClass shouldComponentUpdate: (newProps) -> return true unless isEqualForProperties(newProps, @props, 'renderedRowRange', 'scrollTop', 'lineHeightInPixels', 'mouseWheelScreenRow', 'lineDecorations', - 'scrollViewHeight' + 'scrollViewHeight', 'gpuDisabled' ) {renderedRowRange, pendingChanges, lineDecorations} = newProps diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 63809691b..592f289b1 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -16,18 +16,26 @@ LinesComponent = React.createClass render: -> if @isMounted() - {editor, highlightDecorations, scrollTop, scrollLeft, scrollHeight, scrollWidth} = @props + {editor, highlightDecorations, scrollHeight, scrollWidth} = @props {lineHeightInPixels, defaultCharWidth, scrollViewHeight, scopedCharacterWidthsChangeCount} = @props style = height: Math.max(scrollHeight, scrollViewHeight) width: scrollWidth - WebkitTransform: "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)" + WebkitTransform: @getTransform() # The lines div must have the 'editor-colors' class so it has an opaque # background to avoid sub-pixel anti-aliasing problems on the GPU div {className: 'lines editor-colors', style}, HighlightsComponent({editor, highlightDecorations, lineHeightInPixels, defaultCharWidth, scopedCharacterWidthsChangeCount}) + getTransform: -> + {scrollTop, scrollLeft, gpuDisabled} = @props + + if gpuDisabled + "translate(#{-scrollLeft}px, #{-scrollTop}px)" + else + "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)" + componentWillMount: -> @measuredLines = new WeakSet @lineNodesByLineId = {} @@ -39,7 +47,7 @@ LinesComponent = React.createClass return true unless isEqualForProperties(newProps, @props, 'renderedRowRange', 'lineDecorations', 'highlightDecorations', 'lineHeightInPixels', 'defaultCharWidth', 'scrollTop', 'scrollLeft', 'showIndentGuide', 'scrollingVertically', 'invisibles', 'visible', - 'scrollViewHeight', 'mouseWheelScreenRow', 'scopedCharacterWidthsChangeCount', 'lineWidth' + 'scrollViewHeight', 'mouseWheelScreenRow', 'scopedCharacterWidthsChangeCount', 'lineWidth', 'gpuDisabled' ) {renderedRowRange, pendingChanges} = newProps