190 public AccessControlContext getAccessControlContext() { 191 return accessControlContext; 192 } 193 194 static boolean lockPage() { 195 return Invoker.getInvoker().lock(PAGE_LOCK); 196 } 197 198 static boolean unlockPage() { 199 return Invoker.getInvoker().unlock(PAGE_LOCK); 200 } 201 202 // ************************************************************************* 203 // Backbuffer support 204 // ************************************************************************* 205 206 private WCPageBackBuffer backbuffer; 207 private List<WCRectangle> dirtyRects = new LinkedList<WCRectangle>(); 208 209 private void addDirtyRect(WCRectangle toPaint) { 210 for (Iterator<WCRectangle> it = dirtyRects.iterator(); it.hasNext();) { 211 WCRectangle rect = it.next(); 212 // if already covered 213 if (rect.contains(toPaint)) { 214 return; 215 } 216 // if covers an existing one 217 if (toPaint.contains(rect)) { 218 it.remove(); 219 continue; 220 } 221 WCRectangle u = rect.createUnion(toPaint); 222 // if squre of union is less than summary of squares 223 if (u.getIntWidth() * u.getIntHeight() < 224 rect.getIntWidth() * rect.getIntHeight() + 225 toPaint.getIntWidth() * toPaint.getIntHeight()) 226 { 227 it.remove(); 228 toPaint = u; // replace both the rects with their union 229 continue; 354 buffer.flip(); 355 rq.addBuffer(buffer); 356 currentFrame.addRenderQueue(rq); 357 358 // Now we have to translate "old" dirty rects that fit to the frame's 359 // content as the content is already scrolled at the moment by webkit. 360 if (!dirtyRects.isEmpty()) { 361 WCRectangle scrollRect = new WCRectangle(x, y, w, h); 362 363 for (WCRectangle r: dirtyRects) { 364 if (scrollRect.contains(r)) { 365 if (paintLog.isLoggable(Level.FINEST)) { 366 paintLog.log(Level.FINEST, "translating old dirty rect by the delta: " + r); 367 } 368 r.translate(dx, dy); 369 } 370 } 371 } 372 } 373 374 // Add the dirty (not copied) rect 375 addDirtyRect(new WCRectangle(dx >= 0 ? x : x + w + dx, 376 dy >= 0 ? y : y + h + dy, 377 dx == 0 ? w : Math.abs(dx), 378 dy == 0 ? h : Math.abs(dy))); 379 } 380 381 // Instances of this class may not be accessed and modified concurrently 382 // by multiple threads 383 private static final class RenderFrame { 384 private final List<WCRenderQueue> rqList = 385 new LinkedList<WCRenderQueue>(); 386 private final WCRectangle enclosingRect = new WCRectangle(); 387 388 // Called on: Event thread only 389 private void addRenderQueue(WCRenderQueue rq) { 390 if (rq.isEmpty()) { 391 return; 392 } 393 rqList.add(rq); 394 WCRectangle rqRect = rq.getClip(); 395 if (enclosingRect.isEmpty()) { 396 enclosingRect.setFrame(rqRect.getX(), rqRect.getY(), 397 rqRect.getWidth(), rqRect.getHeight()); 398 } else if (rqRect.isEmpty()) { | 190 public AccessControlContext getAccessControlContext() { 191 return accessControlContext; 192 } 193 194 static boolean lockPage() { 195 return Invoker.getInvoker().lock(PAGE_LOCK); 196 } 197 198 static boolean unlockPage() { 199 return Invoker.getInvoker().unlock(PAGE_LOCK); 200 } 201 202 // ************************************************************************* 203 // Backbuffer support 204 // ************************************************************************* 205 206 private WCPageBackBuffer backbuffer; 207 private List<WCRectangle> dirtyRects = new LinkedList<WCRectangle>(); 208 209 private void addDirtyRect(WCRectangle toPaint) { 210 if (toPaint.getWidth() <= 0 || toPaint.getHeight() <= 0) { 211 return; 212 } 213 for (Iterator<WCRectangle> it = dirtyRects.iterator(); it.hasNext();) { 214 WCRectangle rect = it.next(); 215 // if already covered 216 if (rect.contains(toPaint)) { 217 return; 218 } 219 // if covers an existing one 220 if (toPaint.contains(rect)) { 221 it.remove(); 222 continue; 223 } 224 WCRectangle u = rect.createUnion(toPaint); 225 // if squre of union is less than summary of squares 226 if (u.getIntWidth() * u.getIntHeight() < 227 rect.getIntWidth() * rect.getIntHeight() + 228 toPaint.getIntWidth() * toPaint.getIntHeight()) 229 { 230 it.remove(); 231 toPaint = u; // replace both the rects with their union 232 continue; 357 buffer.flip(); 358 rq.addBuffer(buffer); 359 currentFrame.addRenderQueue(rq); 360 361 // Now we have to translate "old" dirty rects that fit to the frame's 362 // content as the content is already scrolled at the moment by webkit. 363 if (!dirtyRects.isEmpty()) { 364 WCRectangle scrollRect = new WCRectangle(x, y, w, h); 365 366 for (WCRectangle r: dirtyRects) { 367 if (scrollRect.contains(r)) { 368 if (paintLog.isLoggable(Level.FINEST)) { 369 paintLog.log(Level.FINEST, "translating old dirty rect by the delta: " + r); 370 } 371 r.translate(dx, dy); 372 } 373 } 374 } 375 } 376 377 // Add the dirty (not copied) rects 378 addDirtyRect(new WCRectangle(x, dy >= 0 ? y : y + h + dy, 379 w, Math.abs(dy))); 380 addDirtyRect(new WCRectangle(dx >= 0 ? x : x + w + dx, y, 381 Math.abs(dx), h - Math.abs(dy))); 382 } 383 384 // Instances of this class may not be accessed and modified concurrently 385 // by multiple threads 386 private static final class RenderFrame { 387 private final List<WCRenderQueue> rqList = 388 new LinkedList<WCRenderQueue>(); 389 private final WCRectangle enclosingRect = new WCRectangle(); 390 391 // Called on: Event thread only 392 private void addRenderQueue(WCRenderQueue rq) { 393 if (rq.isEmpty()) { 394 return; 395 } 396 rqList.add(rq); 397 WCRectangle rqRect = rq.getClip(); 398 if (enclosingRect.isEmpty()) { 399 enclosingRect.setFrame(rqRect.getX(), rqRect.getY(), 400 rqRect.getWidth(), rqRect.getHeight()); 401 } else if (rqRect.isEmpty()) { |