summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/i915_render.c30
-rw-r--r--src/i965_render.c362
-rw-r--r--src/intel.h2
3 files changed, 255 insertions, 139 deletions
diff --git a/src/i915_render.c b/src/i915_render.c
index 0bf6496a..dbaf1968 100644
--- a/src/i915_render.c
+++ b/src/i915_render.c
@@ -383,15 +383,12 @@ static Bool i915_texture_setup(PicturePtr picture, PixmapPtr pixmap, int unit)
}
static void
-i915_emit_composite_primitive_constant(PixmapPtr dest,
+i915_emit_composite_primitive_constant(intel_screen_private *intel,
int srcX, int srcY,
int maskX, int maskY,
int dstX, int dstY,
int w, int h)
{
- ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
- intel_screen_private *intel = intel_get_screen_private(scrn);
-
OUT_VERTEX(dstX + w);
OUT_VERTEX(dstY + h);
@@ -403,15 +400,12 @@ i915_emit_composite_primitive_constant(PixmapPtr dest,
}
static void
-i915_emit_composite_primitive_identity_source(PixmapPtr dest,
+i915_emit_composite_primitive_identity_source(intel_screen_private *intel,
int srcX, int srcY,
int maskX, int maskY,
int dstX, int dstY,
int w, int h)
{
- ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
- intel_screen_private *intel = intel_get_screen_private(scrn);
-
OUT_VERTEX(dstX + w);
OUT_VERTEX(dstY + h);
OUT_VERTEX((srcX + w) * intel->scale_units[0][0]);
@@ -429,14 +423,12 @@ i915_emit_composite_primitive_identity_source(PixmapPtr dest,
}
static void
-i915_emit_composite_primitive_affine_source(PixmapPtr dest,
+i915_emit_composite_primitive_affine_source(intel_screen_private *intel,
int srcX, int srcY,
int maskX, int maskY,
int dstX, int dstY,
int w, int h)
{
- ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
- intel_screen_private *intel = intel_get_screen_private(scrn);
float src_x[3], src_y[3];
if (!intel_get_transformed_coordinates(srcX, srcY,
@@ -474,15 +466,12 @@ i915_emit_composite_primitive_affine_source(PixmapPtr dest,
}
static void
-i915_emit_composite_primitive_constant_identity_mask(PixmapPtr dest,
+i915_emit_composite_primitive_constant_identity_mask(intel_screen_private *intel,
int srcX, int srcY,
int maskX, int maskY,
int dstX, int dstY,
int w, int h)
{
- ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
- intel_screen_private *intel = intel_get_screen_private(scrn);
-
OUT_VERTEX(dstX + w);
OUT_VERTEX(dstY + h);
OUT_VERTEX((maskX + w) * intel->scale_units[0][0]);
@@ -500,15 +489,12 @@ i915_emit_composite_primitive_constant_identity_mask(PixmapPtr dest,
}
static void
-i915_emit_composite_primitive_identity_source_mask(PixmapPtr dest,
+i915_emit_composite_primitive_identity_source_mask(intel_screen_private *intel,
int srcX, int srcY,
int maskX, int maskY,
int dstX, int dstY,
int w, int h)
{
- ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
- intel_screen_private *intel = intel_get_screen_private(scrn);
-
OUT_VERTEX(dstX + w);
OUT_VERTEX(dstY + h);
OUT_VERTEX((srcX + w) * intel->scale_units[0][0]);
@@ -532,14 +518,12 @@ i915_emit_composite_primitive_identity_source_mask(PixmapPtr dest,
}
static void
-i915_emit_composite_primitive(PixmapPtr dest,
+i915_emit_composite_primitive(intel_screen_private *intel,
int srcX, int srcY,
int maskX, int maskY,
int dstX, int dstY,
int w, int h)
{
- ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
- intel_screen_private *intel = intel_get_screen_private(scrn);
Bool is_affine_src = TRUE, is_affine_mask = TRUE;
int per_vertex;
int tex_unit = 0;
@@ -1156,7 +1140,7 @@ i915_composite(PixmapPtr dest, int srcX, int srcY, int maskX, int maskY,
}
intel->vertex_count += 3;
- intel->prim_emit(dest,
+ intel->prim_emit(intel,
srcX, srcY,
maskX, maskY,
dstX, dstY,
diff --git a/src/i965_render.c b/src/i965_render.c
index bcf7a629..363cf50e 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -1454,6 +1454,237 @@ static void i965_surface_flush(struct intel_screen_private *intel)
priv->dst_bound = priv->src_bound = 0;
}
+static void
+i965_emit_composite_primitive_identity_source(intel_screen_private *intel,
+ int srcX, int srcY,
+ int maskX, int maskY,
+ int dstX, int dstY,
+ int w, int h)
+{
+ OUT_VERTEX(dstX + w);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX((srcX + w) * intel->scale_units[0][0]);
+ OUT_VERTEX((srcY + h) * intel->scale_units[0][1]);
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX(srcX * intel->scale_units[0][0]);
+ OUT_VERTEX((srcY + h) * intel->scale_units[0][1]);
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY);
+ OUT_VERTEX(srcX * intel->scale_units[0][0]);
+ OUT_VERTEX(srcY * intel->scale_units[0][1]);
+}
+
+static void
+i965_emit_composite_primitive_affine_source(intel_screen_private *intel,
+ int srcX, int srcY,
+ int maskX, int maskY,
+ int dstX, int dstY,
+ int w, int h)
+{
+ float src_x[3], src_y[3];
+
+ if (!intel_get_transformed_coordinates(srcX, srcY,
+ intel->transform[0],
+ &src_x[0],
+ &src_y[0]))
+ return;
+
+ if (!intel_get_transformed_coordinates(srcX, srcY + h,
+ intel->transform[0],
+ &src_x[1],
+ &src_y[1]))
+ return;
+
+ if (!intel_get_transformed_coordinates(srcX + w, srcY + h,
+ intel->transform[0],
+ &src_x[2],
+ &src_y[2]))
+ return;
+
+ OUT_VERTEX(dstX + w);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX(src_x[2] * intel->scale_units[0][0]);
+ OUT_VERTEX(src_y[2] * intel->scale_units[0][1]);
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX(src_x[1] * intel->scale_units[0][0]);
+ OUT_VERTEX(src_y[1] * intel->scale_units[0][1]);
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY);
+ OUT_VERTEX(src_x[0] * intel->scale_units[0][0]);
+ OUT_VERTEX(src_y[0] * intel->scale_units[0][1]);
+}
+
+static void
+i965_emit_composite_primitive_identity_source_mask(intel_screen_private *intel,
+ int srcX, int srcY,
+ int maskX, int maskY,
+ int dstX, int dstY,
+ int w, int h)
+{
+ OUT_VERTEX(dstX + w);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX((srcX + w) * intel->scale_units[0][0]);
+ OUT_VERTEX((srcY + h) * intel->scale_units[0][1]);
+ OUT_VERTEX((maskX + w) * intel->scale_units[1][0]);
+ OUT_VERTEX((maskY + h) * intel->scale_units[1][1]);
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX(srcX * intel->scale_units[0][0]);
+ OUT_VERTEX((srcY + h) * intel->scale_units[0][1]);
+ OUT_VERTEX(maskX * intel->scale_units[1][0]);
+ OUT_VERTEX((maskY + h) * intel->scale_units[1][1]);
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY);
+ OUT_VERTEX(srcX * intel->scale_units[0][0]);
+ OUT_VERTEX(srcY * intel->scale_units[0][1]);
+ OUT_VERTEX(maskX * intel->scale_units[1][0]);
+ OUT_VERTEX(maskY * intel->scale_units[1][1]);
+}
+
+static void
+i965_emit_composite_primitive(intel_screen_private *intel,
+ int srcX, int srcY,
+ int maskX, int maskY,
+ int dstX, int dstY,
+ int w, int h)
+{
+ float src_x[3], src_y[3], src_w[3], mask_x[3], mask_y[3], mask_w[3];
+ Bool is_affine = intel->gen4_render_state->composite_op.is_affine;
+
+ if (! intel->render_source_is_solid) {
+ if (is_affine) {
+ if (!intel_get_transformed_coordinates(srcX, srcY,
+ intel->transform[0],
+ &src_x[0],
+ &src_y[0]))
+ return;
+
+ if (!intel_get_transformed_coordinates(srcX, srcY + h,
+ intel->transform[0],
+ &src_x[1],
+ &src_y[1]))
+ return;
+
+ if (!intel_get_transformed_coordinates(srcX + w, srcY + h,
+ intel->transform[0],
+ &src_x[2],
+ &src_y[2]))
+ return;
+ } else {
+ if (!intel_get_transformed_coordinates_3d(srcX, srcY,
+ intel->transform[0],
+ &src_x[0],
+ &src_y[0],
+ &src_w[0]))
+ return;
+
+ if (!intel_get_transformed_coordinates_3d(srcX, srcY + h,
+ intel->transform[0],
+ &src_x[1],
+ &src_y[1],
+ &src_w[1]))
+ return;
+
+ if (!intel_get_transformed_coordinates_3d(srcX + w, srcY + h,
+ intel->transform[0],
+ &src_x[2],
+ &src_y[2],
+ &src_w[2]))
+ return;
+ }
+ }
+
+ if (intel->render_mask) {
+ if (is_affine) {
+ if (!intel_get_transformed_coordinates(maskX, maskY,
+ intel->transform[1],
+ &mask_x[0],
+ &mask_y[0]))
+ return;
+
+ if (!intel_get_transformed_coordinates(maskX, maskY + h,
+ intel->transform[1],
+ &mask_x[1],
+ &mask_y[1]))
+ return;
+
+ if (!intel_get_transformed_coordinates(maskX + w, maskY + h,
+ intel->transform[1],
+ &mask_x[2],
+ &mask_y[2]))
+ return;
+ } else {
+ if (!intel_get_transformed_coordinates_3d(maskX, maskY,
+ intel->transform[1],
+ &mask_x[0],
+ &mask_y[0],
+ &mask_w[0]))
+ return;
+
+ if (!intel_get_transformed_coordinates_3d(maskX, maskY + h,
+ intel->transform[1],
+ &mask_x[1],
+ &mask_y[1],
+ &mask_w[1]))
+ return;
+
+ if (!intel_get_transformed_coordinates_3d(maskX + w, maskY + h,
+ intel->transform[1],
+ &mask_x[2],
+ &mask_y[2],
+ &mask_w[2]))
+ return;
+ }
+ }
+
+ OUT_VERTEX(dstX + w);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX(src_x[2] * intel->scale_units[0][0]);
+ OUT_VERTEX(src_y[2] * intel->scale_units[0][1]);
+ if (!is_affine)
+ OUT_VERTEX(src_w[2]);
+ if (intel->render_mask) {
+ OUT_VERTEX(mask_x[2] * intel->scale_units[1][0]);
+ OUT_VERTEX(mask_y[2] * intel->scale_units[1][1]);
+ if (!is_affine)
+ OUT_VERTEX(mask_w[2]);
+ }
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY + h);
+ OUT_VERTEX(src_x[1] * intel->scale_units[0][0]);
+ OUT_VERTEX(src_y[1] * intel->scale_units[0][1]);
+ if (!is_affine)
+ OUT_VERTEX(src_w[1]);
+ if (intel->render_mask) {
+ OUT_VERTEX(mask_x[1] * intel->scale_units[1][0]);
+ OUT_VERTEX(mask_y[1] * intel->scale_units[1][1]);
+ if (!is_affine)
+ OUT_VERTEX(mask_w[1]);
+ }
+
+ OUT_VERTEX(dstX);
+ OUT_VERTEX(dstY);
+ OUT_VERTEX(src_x[0] * intel->scale_units[0][0]);
+ OUT_VERTEX(src_y[0] * intel->scale_units[0][1]);
+ if (!is_affine)
+ OUT_VERTEX(src_w[0]);
+ if (intel->render_mask) {
+ OUT_VERTEX(mask_x[0] * intel->scale_units[1][0]);
+ OUT_VERTEX(mask_y[0] * intel->scale_units[1][1]);
+ if (!is_affine)
+ OUT_VERTEX(mask_w[0]);
+ }
+}
+
Bool
i965_prepare_composite(int op, PicturePtr source_picture,
PicturePtr mask_picture, PicturePtr dest_picture,
@@ -1579,6 +1810,17 @@ i965_prepare_composite(int op, PicturePtr source_picture,
composite_op->wm_kernel = WM_KERNEL_NOMASK_PROJECTIVE;
}
+ intel->prim_emit = i965_emit_composite_primitive;
+ if (!mask) {
+ if (intel->transform[0] == NULL)
+ intel->prim_emit = i965_emit_composite_primitive_identity_source;
+ else if (composite_op->is_affine)
+ intel->prim_emit = i965_emit_composite_primitive_affine_source;
+ } else {
+ if (intel->transform[0] == NULL && intel->transform[1] == NULL)
+ intel->prim_emit = i965_emit_composite_primitive_identity_source_mask;
+ }
+
intel->floats_per_vertex =
2 + (mask ? 2 : 1) * (composite_op->is_affine ? 2: 3);
@@ -1670,81 +1912,6 @@ i965_composite(PixmapPtr dest, int srcX, int srcY, int maskX, int maskY,
{
ScrnInfoPtr scrn = xf86Screens[dest->drawable.pScreen->myNum];
intel_screen_private *intel = intel_get_screen_private(scrn);
- struct gen4_render_state *render_state = intel->gen4_render_state;
- Bool has_mask;
- float src_x[3], src_y[3], src_w[3], mask_x[3], mask_y[3], mask_w[3];
- Bool is_affine = render_state->composite_op.is_affine;
-
- if (is_affine) {
- if (!intel_get_transformed_coordinates(srcX, srcY,
- intel->transform[0],
- &src_x[0], &src_y[0]))
- return;
- if (!intel_get_transformed_coordinates(srcX, srcY + h,
- intel->transform[0],
- &src_x[1], &src_y[1]))
- return;
- if (!intel_get_transformed_coordinates(srcX + w, srcY + h,
- intel->transform[0],
- &src_x[2], &src_y[2]))
- return;
- } else {
- if (!intel_get_transformed_coordinates_3d(srcX, srcY,
- intel->transform[0],
- &src_x[0], &src_y[0],
- &src_w[0]))
- return;
- if (!intel_get_transformed_coordinates_3d(srcX, srcY + h,
- intel->transform[0],
- &src_x[1], &src_y[1],
- &src_w[1]))
- return;
- if (!intel_get_transformed_coordinates_3d(srcX + w, srcY + h,
- intel->transform[0],
- &src_x[2], &src_y[2],
- &src_w[2]))
- return;
- }
-
- if (intel->render_mask) {
- has_mask = TRUE;
- if (is_affine) {
- if (!intel_get_transformed_coordinates(maskX, maskY,
- intel->
- transform[1],
- &mask_x[0],
- &mask_y[0]))
- return;
- if (!intel_get_transformed_coordinates(maskX, maskY + h,
- intel->
- transform[1],
- &mask_x[1],
- &mask_y[1]))
- return;
- if (!intel_get_transformed_coordinates
- (maskX + w, maskY + h, intel->transform[1],
- &mask_x[2], &mask_y[2]))
- return;
- } else {
- if (!intel_get_transformed_coordinates_3d(maskX, maskY,
- intel->
- transform[1],
- &mask_x[0],
- &mask_y[0],
- &mask_w[0]))
- return;
- if (!intel_get_transformed_coordinates_3d
- (maskX, maskY + h, intel->transform[1], &mask_x[1],
- &mask_y[1], &mask_w[1]))
- return;
- if (!intel_get_transformed_coordinates_3d
- (maskX + w, maskY + h, intel->transform[1],
- &mask_x[2], &mask_y[2], &mask_w[2]))
- return;
- }
- } else {
- has_mask = FALSE;
- }
if (!i965_composite_check_aperture(intel))
intel_batch_submit(scrn);
@@ -1786,46 +1953,11 @@ i965_composite(PixmapPtr dest, int srcX, int srcY, int maskX, int maskY,
intel->vertex_count = intel->vertex_index;
}
- OUT_VERTEX(dstX + w);
- OUT_VERTEX(dstY + h);
- OUT_VERTEX(src_x[2] * intel->scale_units[0][0]);
- OUT_VERTEX(src_y[2] * intel->scale_units[0][1]);
- if (!is_affine)
- OUT_VERTEX(src_w[2]);
- if (has_mask) {
- OUT_VERTEX(mask_x[2] * intel->scale_units[1][0]);
- OUT_VERTEX(mask_y[2] * intel->scale_units[1][1]);
- if (!is_affine)
- OUT_VERTEX(mask_w[2]);
- }
-
- /* rect (x1,y2) */
- OUT_VERTEX(dstX);
- OUT_VERTEX(dstY + h);
- OUT_VERTEX(src_x[1] * intel->scale_units[0][0]);
- OUT_VERTEX(src_y[1] * intel->scale_units[0][1]);
- if (!is_affine)
- OUT_VERTEX(src_w[1]);
- if (has_mask) {
- OUT_VERTEX(mask_x[1] * intel->scale_units[1][0]);
- OUT_VERTEX(mask_y[1] * intel->scale_units[1][1]);
- if (!is_affine)
- OUT_VERTEX(mask_w[1]);
- }
-
- /* rect (x1,y1) */
- OUT_VERTEX(dstX);
- OUT_VERTEX(dstY);
- OUT_VERTEX(src_x[0] * intel->scale_units[0][0]);
- OUT_VERTEX(src_y[0] * intel->scale_units[0][1]);
- if (!is_affine)
- OUT_VERTEX(src_w[0]);
- if (has_mask) {
- OUT_VERTEX(mask_x[0] * intel->scale_units[1][0]);
- OUT_VERTEX(mask_y[0] * intel->scale_units[1][1]);
- if (!is_affine)
- OUT_VERTEX(mask_w[0]);
- }
+ intel->prim_emit(intel,
+ srcX, srcY,
+ maskX, maskY,
+ dstX, dstY,
+ w, h);
intel->vertex_index += 3;
if (INTEL_INFO(intel)->gen < 50) {
diff --git a/src/intel.h b/src/intel.h
index dc03ab6b..a127460a 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -647,7 +647,7 @@ typedef struct intel_screen_private {
} gen6_render_state;
uint32_t prim_offset;
- void (*prim_emit)(PixmapPtr dest,
+ void (*prim_emit)(struct intel_screen_private *intel,
int srcX, int srcY,
int maskX, int maskY,
int dstX, int dstY,