/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <jlong.h>
#include <string.h>
#include "sun_java2d_d3d_D3DPaints_MultiGradient.h"
#include "D3DPaints.h"
#include "D3DContext.h"
#include "D3DRenderQueue.h"
#include "D3DSurfaceData.h"
{
// disable current complex paint state, if necessary
if (paintState > PAINT_ALPHACOLOR) {
if (paintState == PAINT_GRADIENT ||
paintState == PAINT_LIN_GRADIENT ||
{
}
}
// set each component of the current color state to the extra alpha
// value, which will effectively apply the extra alpha to each fragment
return res;
}
{
// no need to reset the current op state here unless the paint
// state really needs to be changed
}
return res;
}
/************************* GradientPaint support ****************************/
{
#if 0
/*
* REMIND: The following code represents the original fast gradient
* implementation. The problem is that it relies on LINEAR
* texture filtering, which does not provide sufficient
* precision on certain hardware (from ATI, notably), which
* will cause visible banding (e.g. 64 shades of gray between
* black and white, instead of the expected 256 shades. For
* correctness on such hardware, it is necessary to use a
* shader-based approach that does not suffer from these
* precision issues (see below). This original implementation
* is about 16x faster than software, whereas the shader-based
* implementation is only about 4x faster than software (still
* impressive). For simplicity, we will always use the
* shader-based version for now, but in the future we could
* consider using the fast path for certain hardware (that does
* not exhibit the problem) or provide a flag to allow developers
* to control which path we take (for those that are less
* concerned about quality). Therefore, I'll leave this code
* here (currently disabled) for future use.
*/
// this will initialize the gradient texture, if necessary
// update the texture containing the gradient colors
{
pGradientTex->UnlockRect(0);
}
#else
// update the "uniform" values
// set up texture coordinate transform with identity matrix, which
// will have the effect of passing the current window-space coordinates
// through to the TEXCOORD0/1 register used by the basic gradient
// pixel shader
#endif
// pixel state has been set appropriately in D3DPaints_ResetPaint()
return res;
}
/************************** TexturePaint support ****************************/
{
// offset by a half texel to correctly map texels to pixels
// m02 = tx * m00 + ty * m01 + m02;
// m12 = tx * m10 + ty * m11 + m12;
// pixel state has been set appropriately in D3DPaints_ResetPaint()
return res;
}
/****************** Shared MultipleGradientPaint support ********************/
/** Composes the given parameters as flags into the given flags variable.*/
do { \
} while (0)
/**
* The maximum number of gradient "stops" supported by the fragment shader
* and related code. When the MULTI_GRAD_LARGE flag is set, we will use
* MAX_FRACTIONS_LARGE; otherwise, we use MAX_FRACTIONS_SMALL. By having
* two separate values, we can have one highly optimized shader (SMALL) that
* shader that supports more stops.
*/
#define MAX_FRACTIONS \
/**
* Called from the D3DPaints_SetLinear/RadialGradientPaint() methods
*/
static HRESULT
void *pFractions, void *pPixels)
{
int i;
int fIndex = 0;
// update the "uniform" fractions and scale factors
for (i = 0; i < maxFractions; i++) {
fractions[i] : 0.0f;
fIndex += 4;
}
// this will initialize the multi-gradient texture, if necessary
// update the texture containing the gradient colors
if (numStops < MAX_MULTI_GRADIENT_COLORS) {
// when we don't have enough colors to fill the entire
// color gradient, we have to replicate the last color
// in the right-most texel for the NO_CYCLE case where the
// texcoord is sometimes forced to 1.0
}
// set the gradient texture and update relevant state
// set up texture coordinate transform with identity matrix, which
// will have the effect of passing the current window-space coordinates
// through to the TEXCOORD0/1 register used by the multi-stop
// gradient pixel shader
return res;
}
/********************** LinearGradientPaint support *************************/
{
// update the common "uniform" values (fractions and colors)
// update the other "uniform" values
// pixel state has been set appropriately in D3DPaints_ResetPaint()
return res;
}
/********************** RadialGradientPaint support *************************/
{
// update the common "uniform" values (fractions and colors)
// update the other "uniform" values
// pack a few unrelated, precalculated values into a single float4
// pixel state has been set appropriately in D3DPaints_ResetPaint()
return res;
}