Skip to content

Commit

Permalink
8273946: Move clearQuad method to BaseShaderGraphics superclass
Browse files Browse the repository at this point in the history
Reviewed-by: jpereda, nlisker
  • Loading branch information
kevinrushforth committed Sep 22, 2021
1 parent 5c355fa commit 338b999
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 41 deletions.
Expand Up @@ -26,17 +26,15 @@
package com.sun.prism.d3d;

import com.sun.javafx.geom.transform.Affine3D;
import com.sun.prism.CompositeMode;
import com.sun.prism.Graphics;
import com.sun.prism.RenderTarget;
import com.sun.prism.impl.PrismSettings;
import com.sun.prism.impl.ps.BaseShaderGraphics;
import com.sun.prism.paint.Color;
import com.sun.prism.paint.Paint;

class D3DGraphics extends BaseShaderGraphics implements D3DContextSource {

private D3DContext context;
private final D3DContext context;

private D3DGraphics(D3DContext context, RenderTarget target) {
super(context, target);
Expand Down Expand Up @@ -65,24 +63,6 @@ static Graphics create(RenderTarget target, D3DContext context) {
return new D3DGraphics(context, target);
}

@Override
public void clearQuad(float x1, float y1, float x2, float y2) {
// note that unlike clear(), this method does not currently
// attempt to clear the depth buffer...
context.setRenderTarget(this);
context.flushVertexBuffer();
// set the blend mode to CLEAR and any regular Color as paint
CompositeMode oldMode = getCompositeMode();
setCompositeMode(CompositeMode.CLEAR);
Paint oldPaint = getPaint();
setPaint(Color.BLACK); // any color will do...
fillQuad(x1, y1, x2, y2);
context.flushVertexBuffer();
// restore prior paint and blend mode
setPaint(oldPaint);
setCompositeMode(oldMode);
}

@Override
public void clear(Color color) {
context.validateClearOp(this);
Expand Down
Expand Up @@ -27,12 +27,10 @@

import com.sun.javafx.geom.transform.BaseTransform;
import com.sun.javafx.sg.prism.NGCamera;
import com.sun.prism.CompositeMode;
import com.sun.prism.GraphicsPipeline;
import com.sun.prism.RenderTarget;
import com.sun.prism.impl.ps.BaseShaderGraphics;
import com.sun.prism.paint.Color;
import com.sun.prism.paint.Paint;

public class ES2Graphics extends BaseShaderGraphics {

Expand All @@ -57,24 +55,6 @@ static void clearBuffers(ES2Context context, Color color, boolean clearColor,

}

@Override
public void clearQuad(float x1, float y1, float x2, float y2) {
// note that unlike clear(), this method does not currently
// attempt to clear the depth buffer...
context.setRenderTarget(this);
context.flushVertexBuffer();
CompositeMode mode = getCompositeMode();
// set the blend mode to CLEAR
setCompositeMode(CompositeMode.CLEAR);
Paint oldPaint = getPaint();
setPaint(Color.BLACK); // any color will do...
fillQuad(x1, y1, x2, y2);
context.flushVertexBuffer();
setPaint(oldPaint);
// restore default blend mode
setCompositeMode(mode);
}

@Override
public void clear(Color color) {
context.validateClearOp(this);
Expand Down
Expand Up @@ -125,6 +125,24 @@ public void setPaint(Paint paint) {

public final NGLightBase[] getLights() { return this.lights; }

@Override
public void clearQuad(float x1, float y1, float x2, float y2) {
// note that unlike clear(), this method does not currently
// attempt to clear the depth buffer...
context.setRenderTarget(this);
context.flushVertexBuffer();
// set the blend mode to CLEAR and any regular Color as paint
CompositeMode oldMode = getCompositeMode();
setCompositeMode(CompositeMode.CLEAR);
Paint oldPaint = getPaint();
setPaint(Color.BLACK); // any color will do...
fillQuad(x1, y1, x2, y2);
context.flushVertexBuffer();
// restore prior paint and blend mode
setPaint(oldPaint);
setCompositeMode(oldMode);
}

@Override
public void drawTexture(Texture tex,
float dx1, float dy1, float dx2, float dy2,
Expand Down

1 comment on commit 338b999

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.