private void setSurfaces(AccelSurface srcData, AccelSurface dstData) { // assert rq.lock.isHeldByCurrentThread(); rq.ensureCapacityAndAlignment(20, 4); buf.putInt(SET_SURFACES); buf.putLong(srcData.getNativeOps()); buf.putLong(dstData.getNativeOps()); }
/** * Fetches the BufferedContextContext associated with the dst. surface and validates the context * using the given parameters. Most rendering operations will call this method first in order to * set the necessary state before issuing rendering commands. * * <p>Note: must be called while the RenderQueue lock is held. * * @throws InvalidPipeException if either src or dest surface is not valid or lost * @see RenderQueue#lock * @see RenderQueue#unlock */ public static void validateContext( AccelSurface srcData, AccelSurface dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags) { // assert rq.lock.isHeldByCurrentThread(); BufferedContext d3dc = dstData.getContext(); d3dc.validate(srcData, dstData, clip, comp, xform, paint, sg2d, flags); }
/** * Validates the given parameters against the current state for this context. If this context is * not current, it will be made current for the given source and destination surfaces, and the * viewport will be updated. Then each part of the context state (clip, composite, etc.) is * checked against the previous value. If the value has changed since the last call to validate(), * it will be updated accordingly. * * <p>Note that the SunGraphics2D parameter is only used for the purposes of validating a * (non-null) Paint parameter. In all other cases it is safe to pass a null SunGraphics2D and it * will be ignored. * * <p>Note: must be called while the RenderQueue lock is held. * * @throws InvalidPipeException if either src or dest surface is not valid or lost */ public void validate( AccelSurface srcData, AccelSurface dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags) { // assert rq.lock.isHeldByCurrentThread(); boolean updateClip = false; boolean updatePaint = false; if (!dstData.isValid() || dstData.isSurfaceLost() || srcData.isSurfaceLost()) { invalidateContext(); throw new InvalidPipeException("bounds changed or surface lost"); } if (paint instanceof Color) { // REMIND: not 30-bit friendly int newRGB = ((Color) paint).getRGB(); if (isValidatedPaintAColor) { if (newRGB != validatedRGB) { validatedRGB = newRGB; updatePaint = true; } } else { validatedRGB = newRGB; updatePaint = true; isValidatedPaintAColor = true; } } else if (validatedPaint != paint) { updatePaint = true; // this should be set when we are switching from paint to color // in which case this condition will be true isValidatedPaintAColor = false; } if ((currentContext != this) || (srcData != validatedSrcData) || (dstData != validatedDstData)) { if (dstData != validatedDstData) { // the clip is dependent on the destination surface, so we // need to update it if we have a new destination surface updateClip = true; } if (paint == null) { // make sure we update the color state (otherwise, it might // not be updated if this is the first time the context // is being validated) updatePaint = true; } // update the current source and destination surfaces setSurfaces(srcData, dstData); currentContext = this; validatedSrcData = srcData; validatedDstData = dstData; } // validate clip if ((clip != validatedClip) || updateClip) { if (clip != null) { if (updateClip || validatedClip == null || !(validatedClip.isRectangular() && clip.isRectangular()) || ((clip.getLoX() != validatedClip.getLoX() || clip.getLoY() != validatedClip.getLoY() || clip.getHiX() != validatedClip.getHiX() || clip.getHiY() != validatedClip.getHiY()))) { setClip(clip); } } else { resetClip(); } validatedClip = clip; } // validate composite (note that a change in the context flags // may require us to update the composite state, even if the // composite has not changed) if ((comp != validatedComp) || (flags != validatedFlags)) { if (comp != null) { setComposite(comp, flags); } else { resetComposite(); } // the paint state is dependent on the composite state, so make // sure we update the color below updatePaint = true; validatedComp = comp; validatedFlags = flags; } // validate transform boolean txChanged = false; if (xform == null) { if (xformInUse) { resetTransform(); xformInUse = false; txChanged = true; } else if (sg2d != null) { if (transX != sg2d.transX || transY != sg2d.transY) { txChanged = true; } } if (sg2d != null) { transX = sg2d.transX; transY = sg2d.transY; } } else { setTransform(xform); xformInUse = true; txChanged = true; } // non-Color paints may require paint revalidation if (!isValidatedPaintAColor && txChanged) { updatePaint = true; } // validate paint if (updatePaint) { if (paint != null) { BufferedPaints.setPaint(rq, sg2d, paint, flags); } else { BufferedPaints.resetPaint(rq); } validatedPaint = paint; } // mark dstData dirty // REMIND: is this really needed now? we do it in SunGraphics2D.. dstData.markDirty(); }