Skip to content
Permalink
Browse files

8238276: ComponentPeer.xxxImage are not implemented in some peers

Reviewed-by: aivanov
  • Loading branch information
mrserb committed Feb 8, 2020
1 parent cf83f8e commit 1b3b413ee6f55d4277d3061d3bd9d3100a7c6fe8
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,8 +53,6 @@
import java.awt.event.MouseWheelEvent;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
@@ -75,7 +73,6 @@
import sun.awt.SunToolkit;
import sun.awt.event.IgnorePaintEvent;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.ToolkitImage;
import sun.java2d.SunGraphics2D;
import sun.java2d.opengl.OGLRenderQueue;
import sun.java2d.pipe.Region;
@@ -993,11 +990,6 @@ public boolean requestFocus(Component lightweightChild, boolean temporary,
return false;
}

@Override
public final Image createImage(final ImageProducer producer) {
return new ToolkitImage(producer);
}

@Override
public final Image createImage(final int width, final int height) {
return getLWGC().createAcceleratedImage(getTarget(), width, height);
@@ -1008,18 +1000,6 @@ public final VolatileImage createVolatileImage(final int w, final int h) {
return new SunVolatileImage(getTarget(), w, h);
}

@Override
public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
// TODO: is it a right/complete implementation?
return Toolkit.getDefaultToolkit().prepareImage(img, w, h, o);
}

@Override
public int checkImage(Image img, int w, int h, ImageObserver o) {
// TODO: is it a right/complete implementation?
return Toolkit.getDefaultToolkit().checkImage(img, w, h, o);
}

@Override
public boolean handlesWheelScrolling() {
// TODO: not implemented
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,34 @@

package sun.lwawt.macosx;

import java.awt.*;
import java.awt.event.FocusEvent.Cause;
import java.awt.peer.*;
import java.awt.AWTEvent;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FileDialog;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Window;
import java.awt.event.FocusEvent.Cause;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.FileDialogPeer;
import java.io.File;
import java.io.FilenameFilter;
import java.security.AccessController;
import java.util.List;
import java.io.*;

import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
@@ -248,11 +267,6 @@ public boolean canDetermineObscurity() {
return false;
}

@Override
public int checkImage(Image img, int w, int h, ImageObserver o) {
return 0;
}

@Override
public void coalescePaintEvent(PaintEvent e) {
}
@@ -262,11 +276,6 @@ public void createBuffers(int numBuffers, BufferCapabilities caps)
throws AWTException {
}

@Override
public Image createImage(ImageProducer producer) {
return null;
}

@Override
public Image createImage(int width, int height) {
return null;
@@ -357,11 +366,6 @@ public void layout() {
public void paint(Graphics g) {
}

@Override
public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
return false;
}

@Override
public void print(Graphics g) {
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -3633,10 +3633,6 @@ public boolean imageUpdate(Image img, int infoflags,
* @since 1.0
*/
public Image createImage(ImageProducer producer) {
ComponentPeer peer = this.peer;
if ((peer != null) && ! (peer instanceof LightweightPeer)) {
return peer.createImage(producer);
}
return getToolkit().createImage(producer);
}

@@ -3752,16 +3748,7 @@ public boolean prepareImage(Image image, ImageObserver observer) {
*/
public boolean prepareImage(Image image, int width, int height,
ImageObserver observer) {
ComponentPeer peer = this.peer;
if (peer instanceof LightweightPeer) {
return (parent != null)
? parent.prepareImage(image, width, height, observer)
: getToolkit().prepareImage(image, width, height, observer);
} else {
return (peer != null)
? peer.prepareImage(image, width, height, observer)
: getToolkit().prepareImage(image, width, height, observer);
}
return getToolkit().prepareImage(image, width, height, observer);
}

/**
@@ -3824,16 +3811,7 @@ public int checkImage(Image image, ImageObserver observer) {
*/
public int checkImage(Image image, int width, int height,
ImageObserver observer) {
ComponentPeer peer = this.peer;
if (peer instanceof LightweightPeer) {
return (parent != null)
? parent.checkImage(image, width, height, observer)
: getToolkit().checkImage(image, width, height, observer);
} else {
return (peer != null)
? peer.checkImage(image, width, height, observer)
: getToolkit().checkImage(image, width, height, observer);
}
return getToolkit().checkImage(image, width, height, observer);
}

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,26 @@

package java.awt.peer;

import java.awt.*;
import java.awt.event.PaintEvent;
import java.awt.AWTEvent;
import java.awt.AWTException;
import java.awt.BufferCapabilities;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.FocusEvent.Cause;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;

import sun.java2d.pipe.Region;


/**
* The peer interface for {@link Component}. This is the top level peer
* interface for widgets and defines the bulk of methods for AWT component
@@ -354,18 +363,6 @@ boolean requestFocus(Component lightweightChild, boolean temporary,
*/
boolean isFocusable();

/**
* Creates an image using the specified image producer.
*
* @param producer the image producer from which the image pixels will be
* produced
*
* @return the created image
*
* @see Component#createImage(ImageProducer)
*/
Image createImage(ImageProducer producer);

/**
* Creates an empty image with the specified width and height. This is
* generally used as a non-accelerated backbuffer for drawing onto the
@@ -397,38 +394,6 @@ boolean requestFocus(Component lightweightChild, boolean temporary,
// TODO: Include capabilities here and fix Component#createVolatileImage
VolatileImage createVolatileImage(int width, int height);

/**
* Prepare the specified image for rendering on this component. This should
* start loading the image (if not already loaded) and create an
* appropriate screen representation.
*
* @param img the image to prepare
* @param w the width of the screen representation
* @param h the height of the screen representation
* @param o an image observer to observe the progress
*
* @return {@code true} if the image is already fully prepared,
* {@code false} otherwise
*
* @see Component#prepareImage(Image, int, int, ImageObserver)
*/
boolean prepareImage(Image img, int w, int h, ImageObserver o);

/**
* Determines the status of the construction of the screen representation
* of the specified image.
*
* @param img the image to check
* @param w the target width
* @param h the target height
* @param o the image observer to notify
*
* @return the status as bitwise ORed ImageObserver flags
*
* @see Component#checkImage(Image, int, int, ImageObserver)
*/
int checkImage(Image img, int w, int h, ImageObserver o);

/**
* Returns the graphics configuration that corresponds to this component.
*
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,28 +31,26 @@
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.FocusEvent.Cause;
import java.awt.Point;
import java.awt.Event;
import java.awt.Rectangle;
import java.awt.event.FocusEvent.Cause;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
import java.awt.peer.CanvasPeer;
import java.awt.peer.LightweightPeer;
import java.awt.peer.PanelPeer;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.Rectangle;
import sun.java2d.pipe.Region;
import java.awt.peer.LightweightPeer;
import java.awt.peer.PanelPeer;

import sun.java2d.pipe.Region;

/**
* Implements the LightweightPeer interface for use in lightweight components
@@ -74,7 +72,6 @@
* @author Timothy Prinzing
* @author Michael Martak
*/

public class NullComponentPeer implements LightweightPeer,
CanvasPeer, PanelPeer {

@@ -183,22 +180,10 @@ public void setCursor(Cursor cursor) {
return false;
}

public Image createImage(ImageProducer producer) {
return null;
}

public Image createImage(int width, int height) {
return null;
}

public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
return false;
}

public int checkImage(Image img, int w, int h, ImageObserver o) {
return 0;
}

public Dimension preferredSize() {
return getPreferredSize();
}

0 comments on commit 1b3b413

Please sign in to comment.