From: <k_s...@us...> - 2008-09-06 07:48:32
|
Revision: 13533 http://jedit.svn.sourceforge.net/jedit/?rev=13533&view=rev Author: k_satoda Date: 2008-09-06 07:48:29 +0000 (Sat, 06 Sep 2008) Log Message: ----------- Removed FastRepaintManager because the effect seemed to be not noticeable and not stable over runtime environments, while it broke Background plugin (SF.net Plugin Bugs #1620694) and consumed much memory. Some performance measures were reported in this thread on jedit-devel. "[ jEdit-devel ] Disabling FastRepaintManager" http://www.nabble.com/Disabling-FastRepaintManager-to19210597.html Modified Paths: -------------- jEdit/trunk/doc/CHANGES.txt jEdit/trunk/org/gjt/sp/jedit/textarea/BufferHandler.java jEdit/trunk/org/gjt/sp/jedit/textarea/TextArea.java jEdit/trunk/org/gjt/sp/jedit/textarea/TextAreaPainter.java Removed Paths: ------------- jEdit/trunk/org/gjt/sp/jedit/textarea/FastRepaintManager.java Modified: jEdit/trunk/doc/CHANGES.txt =================================================================== --- jEdit/trunk/doc/CHANGES.txt 2008-09-05 08:22:04 UTC (rev 13532) +++ jEdit/trunk/doc/CHANGES.txt 2008-09-06 07:48:29 UTC (rev 13533) @@ -39,6 +39,12 @@ available modes, the user can select one and a new file is created under that mode. (SF.net patch #1829669 - Eric Berry) +- Removed own back buffers for textarea, which were meant to speed up + painting textare, because the effect seemed to be not noticeable and + not stable over runtime environments, while it broke Background plugin + (SF.net Plugin Bugs #1620694) and consumed much memory. + (Kazutoshi Satoda) + }}} {{{ Docker Plugin features merged into jEdit Core - New actions: View - Docking - Load|Save docking layout (of current mode) Modified: jEdit/trunk/org/gjt/sp/jedit/textarea/BufferHandler.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/textarea/BufferHandler.java 2008-09-05 08:22:04 UTC (rev 13532) +++ jEdit/trunk/org/gjt/sp/jedit/textarea/BufferHandler.java 2008-09-06 07:48:29 UTC (rev 13533) @@ -424,7 +424,6 @@ private void delayUpdate(int startLine, int endLine) { textArea.chunkCache.invalidateChunksFromPhys(startLine); - textArea.repaintMgr.setFastScroll(false); if(!delayedUpdate) { Deleted: jEdit/trunk/org/gjt/sp/jedit/textarea/FastRepaintManager.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/textarea/FastRepaintManager.java 2008-09-05 08:22:04 UTC (rev 13532) +++ jEdit/trunk/org/gjt/sp/jedit/textarea/FastRepaintManager.java 2008-09-06 07:48:29 UTC (rev 13533) @@ -1,163 +0,0 @@ -/* - * FastRepaintManager.java - * :tabSize=8:indentSize=8:noTabs=false: - * :folding=explicit:collapseFolds=1: - * - * Copyright (C) 2005 Slava Pestov - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package org.gjt.sp.jedit.textarea; - -//{{{ Imports -import java.awt.*; -//}}} - -/** - * Manages blitting the offscreen graphics context to speed up scrolling. - * The text area does not use Swing's built-in double buffering, so that - * we have access to the graphics context for fast scrolling. - * @author Slava Pestov - * @version $Id$ - */ -class FastRepaintManager -{ - //{{{ FastRepaintManager constructor - FastRepaintManager(TextArea textArea, - TextAreaPainter painter) - { - this.textArea = textArea; - this.painter = painter; - } //}}} - - //{{{ updateGraphics() method - /** - * Prepare the graphics environment. - * This is only called by the TextAreaPainter when it is resized - */ - void updateGraphics() - { - if(gfx != null) - gfx.dispose(); - - int width = painter.getWidth(); - int height = painter.getHeight(); - /* A little hack */ - if(width <= 0) - width = 1; - if(height <= 0) - height = 1; - img = painter.getGraphicsConfiguration() - .createCompatibleImage(width,height, - Transparency.OPAQUE); - gfx = (Graphics2D)img.getGraphics(); - gfx.clipRect(0,0,painter.getWidth(),painter.getHeight()); - fastScroll = false; - } //}}} - - //{{{ getGraphics() method - Graphics2D getGraphics() - { - return gfx; - } //}}} - - //{{{ RepaintLines class - static class RepaintLines - { - final int first; - final int last; - - RepaintLines(int first, int last) - { - this.first = first; - this.last = last; - } - - @Override - public String toString() - { - return "RepaintLines[" + first + ',' + last + ']'; - } - } //}}} - - //{{{ prepareGraphics() method - RepaintLines prepareGraphics(Rectangle clipRect, int firstLine, - Graphics2D gfx) - { - gfx.setFont(painter.getFont()); - gfx.setColor(painter.getBackground()); - - int lineHeight = gfx.getFontMetrics().getHeight(); - - if(fastScroll) - { - int lineDelta = this.firstLine - firstLine; - int visibleLines = textArea.getVisibleLines(); - - if(lineDelta > -visibleLines - && lineDelta < visibleLines) - { - int yDelta = lineDelta * lineHeight; - if(lineDelta < 0) - { - gfx.copyArea(0,-yDelta,painter.getWidth(), - painter.getHeight() + yDelta,0,yDelta); - return new RepaintLines( - visibleLines + this.firstLine - - firstLine - 1, - visibleLines - 1); - } - else if(lineDelta > 0) - { - gfx.copyArea(0,0,painter.getWidth(), - painter.getHeight() - yDelta,0,yDelta); - return new RepaintLines(0, - this.firstLine - firstLine); - } - } - } - - // Because the clipRect's height is usually an even multiple - // of the font height, we subtract 1 from it, otherwise one - // too many lines will always be painted. - return new RepaintLines( - clipRect.y / lineHeight, - (clipRect.y + clipRect.height - 1) / lineHeight); - } //}}} - - //{{{ paint() method - void paint(Graphics g) - { - firstLine = textArea.getFirstLine(); - g.drawImage(img,0,0,null); - } //}}} - - //{{{ setFastScroll() method - void setFastScroll(boolean fastScroll) - { - this.fastScroll = fastScroll; - } //}}} - - //{{{ Private members - private final TextArea textArea; - private final TextAreaPainter painter; - private Graphics2D gfx; - private Image img; - private boolean fastScroll; - /* Most recently rendered first line */ - private int firstLine; - //}}} -} Modified: jEdit/trunk/org/gjt/sp/jedit/textarea/TextArea.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/textarea/TextArea.java 2008-09-05 08:22:04 UTC (rev 13532) +++ jEdit/trunk/org/gjt/sp/jedit/textarea/TextArea.java 2008-09-06 07:48:29 UTC (rev 13533) @@ -268,7 +268,6 @@ selectionManager = new SelectionManager(this); chunkCache = new ChunkCache(this); painter = new TextAreaPainter(this); - repaintMgr = new FastRepaintManager(this,painter); gutter = new Gutter(this); gutter.setMouseActionsProvider(new MouseActions(propertyManager, "gutter")); listenerList = new EventListenerList(); @@ -544,7 +543,6 @@ this.buffer.beginCompoundEdit(); chunkCache.setBuffer(buffer); - repaintMgr.setFastScroll(false); propertiesChanged(); if(displayManager != null) @@ -4795,7 +4793,6 @@ displayManager.notifyScreenLineChanges(); } - repaintMgr.setFastScroll(false); chunkCache.invalidateAll(); gutter.repaint(); painter.repaint(); @@ -4860,7 +4857,6 @@ final Segment lineSegment = new Segment(); MouseInputAdapter mouseHandler; final ChunkCache chunkCache; - final FastRepaintManager repaintMgr; DisplayManager displayManager; final SelectionManager selectionManager; /** @@ -4974,7 +4970,6 @@ //{{{ foldStructureChanged() method void foldStructureChanged() { - repaintMgr.setFastScroll(false); chunkCache.invalidateAll(); recalculateLastPhysicalLine(); repaint(); @@ -5225,8 +5220,6 @@ if(!buffer.isTransactionInProgress()) _finishCaretUpdate(); /* otherwise DisplayManager.BufferChangeHandler calls */ - - repaintMgr.setFastScroll(false); } //}}} //{{{ fireCaretEvent() method Modified: jEdit/trunk/org/gjt/sp/jedit/textarea/TextAreaPainter.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/textarea/TextAreaPainter.java 2008-09-05 08:22:04 UTC (rev 13532) +++ jEdit/trunk/org/gjt/sp/jedit/textarea/TextAreaPainter.java 2008-09-06 07:48:29 UTC (rev 13533) @@ -169,8 +169,6 @@ textArea.propertiesChanged(); textArea.updateMaxHorizontalScrollWidth(); textArea.scrollBarsInitialized = true; - - textArea.repaintMgr.updateGraphics(); } //}}} //{{{ getFocusTraversalKeysEnabled() method @@ -740,7 +738,7 @@ gfx.setColor(getBackground()); gfx.fillRect(clipRect.x,clipRect.y,clipRect.width,clipRect.height); } - else if(Debug.DISABLE_FASTREPAINTMANAGER) + else { long prepareTime = System.nanoTime(); // Because the clipRect's height is usually an even multiple @@ -763,36 +761,7 @@ if(Debug.PAINT_TIMER && numLines >= 1) Log.log(Log.DEBUG,this,"repainting " + numLines + " lines took " + prepareTime + "/" + linesTime + " ns"); } - else - { - Graphics2D backBuffer = textArea.repaintMgr.getGraphics(); - long prepareTime = System.nanoTime(); - FastRepaintManager.RepaintLines lines - = textArea.repaintMgr.prepareGraphics(clipRect, - textArea.getFirstLine(),backBuffer); - prepareTime = (System.nanoTime() - prepareTime); - - long linesTime = System.nanoTime(); - int numLines = (lines.last - lines.first + 1); - int y = lines.first * lineHeight; - backBuffer.fillRect(0,y,getWidth(),numLines * lineHeight); - extensionMgr.paintScreenLineRange(textArea,backBuffer, - lines.first,lines.last,y,lineHeight); - linesTime = (System.nanoTime() - linesTime); - - textArea.repaintMgr.setFastScroll( - clipRect.equals(new Rectangle(0,0, - getWidth(),getHeight()))); - - long blitTime = System.nanoTime(); - textArea.repaintMgr.paint(gfx); - blitTime = (System.nanoTime() - blitTime); - - if(Debug.PAINT_TIMER && numLines >= 1) - Log.log(Log.DEBUG,this,"repainting " + numLines + " lines took " + prepareTime + "/" + linesTime + "/" + blitTime + " ns"); - } - textArea.updateMaxHorizontalScrollWidth(); } //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |