Bug 599118 - Followup: Respect source pattern filter when using fastblit. r=joe a=test-bustage
authorBas Schouten <bschouten@mozilla.com>
Fri, 24 Sep 2010 19:55:55 +0200
changeset 54634 3c934d803bd7b6a920c7d66c01898897f039ca7d
parent 54633 6252117bbc42e71786ef7a67ce0ee93f2e70749e
child 54635 8cde825e06bba5ed12b669c728e3594cf64b6892
push id15964
push userbschouten@mozilla.com
push dateFri, 24 Sep 2010 17:56:17 +0000
treeherdermozilla-central@3c934d803bd7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe, test-bustage
bugs599118
milestone2.0b7pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 599118 - Followup: Respect source pattern filter when using fastblit. r=joe a=test-bustage
gfx/cairo/cairo/src/cairo-d2d-surface.cpp
--- a/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-d2d-surface.cpp
@@ -2642,16 +2642,17 @@ static cairo_int_status_t
 }
 
 static cairo_int_status_t
 _cairo_d2d_blend_surface(cairo_d2d_surface_t *dst,
 			 cairo_d2d_surface_t *src,
 		 	 const cairo_matrix_t *transform,
 			 cairo_box_t *box,
 			 cairo_clip_t *clip,
+                         cairo_filter_t filter,
 			 float opacity)
 {
     if (dst == src) {
 	// We cannot do self-blend.
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
     cairo_int_status_t rv = CAIRO_INT_STATUS_SUCCESS;
 
@@ -2693,52 +2694,60 @@ static cairo_int_status_t
     }
 
     D2D1_RECT_F rectDst;
     rectDst.left = (float)x1;
     rectDst.top = (float)y1;
     rectDst.right = (float)x2;
     rectDst.bottom = (float)y2;
 
+    D2D1_BITMAP_INTERPOLATION_MODE interpMode =
+      D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
+
+    if (filter == CAIRO_FILTER_NEAREST) {
+      interpMode = D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
+    }
+
     dst->rt->DrawBitmap(src->surfaceBitmap,
 			rectDst,
 			opacity,
-			D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
+			interpMode,
 			rectSrc);
 
     return rv;
 }
 /**
  * This function will text if we can use GPU mem cpy to execute an operation with
  * a surface pattern. If box is NULL it will operate on the entire dst surface.
  */
 static cairo_int_status_t
 _cairo_d2d_try_fastblit(cairo_d2d_surface_t *dst,
 		        cairo_surface_t *src,
 		        cairo_box_t *box,
 		        const cairo_matrix_t *matrix,
 		        cairo_clip_t *clip,
 		        cairo_operator_t op,
+                        cairo_filter_t filter,
 			float opacity = 1.0f)
 {
     if (op == CAIRO_OPERATOR_OVER && src->content == CAIRO_CONTENT_COLOR) {
 	op = CAIRO_OPERATOR_SOURCE;
     }
     if (op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_OVER) {
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
     /* For now we do only D2D sources */
     if (src->type != CAIRO_SURFACE_TYPE_D2D) {
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
     cairo_d2d_surface_t *d2dsrc = reinterpret_cast<cairo_d2d_surface_t*>(src);
     if (op == CAIRO_OPERATOR_OVER && matrix->xy == 0 && matrix->yx == 0) {
-	return _cairo_d2d_blend_surface(dst, d2dsrc, matrix, box, clip, opacity);
+	return _cairo_d2d_blend_surface(dst, d2dsrc, matrix, box, clip, filter, opacity);
     }
     
     if (op == CAIRO_OPERATOR_OVER || opacity != 1.0f) {
 	// Past this point we will never get into a situation where we can
 	// support OVER.
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
     
@@ -2999,17 +3008,18 @@ static cairo_int_status_t
 	return _cairo_d2d_clear(d2dsurf, clip);
     }
 
     if (source->type == CAIRO_PATTERN_TYPE_SURFACE) {
 	const cairo_surface_pattern_t *surf_pattern = 
 	    reinterpret_cast<const cairo_surface_pattern_t*>(source);
 
 	status = _cairo_d2d_try_fastblit(d2dsurf, surf_pattern->surface,
-				         NULL, &source->matrix, clip, op);
+				         NULL, &source->matrix, clip,
+                                         op, source->filter);
 
 	if (status != CAIRO_INT_STATUS_UNSUPPORTED) {
 	    return status;
 	}
     }
     RefPtr<ID2D1RenderTarget> target_rt = d2dsurf->rt;
 #ifndef ALWAYS_MANUAL_COMPOSITE
     if (op != CAIRO_OPERATOR_OVER) {
@@ -3100,16 +3110,17 @@ static cairo_int_status_t
 	    cairo_box_t box;
 	    _cairo_box_from_rectangle(&box, &extents);
 	    cairo_int_status_t rv = _cairo_d2d_try_fastblit(d2dsurf,
 							    surf_pattern->surface,
 							    &box,
 							    &source->matrix,
 							    clip,
 							    op,
+                                                            source->filter,
 							    solidAlphaValue);
 	    if (rv != CAIRO_INT_STATUS_UNSUPPORTED) {
 		return rv;
 	    }
 	}
     }
 
     RefPtr<ID2D1Brush> brush = _cairo_d2d_create_brush_for_pattern(d2dsurf, source);
@@ -3270,17 +3281,18 @@ static cairo_int_status_t
     cairo_d2d_surface_t *d2dsurf = static_cast<cairo_d2d_surface_t*>(surface);
     cairo_box_t box;
     bool is_box = _cairo_path_fixed_is_box(path, &box);
 
     if (is_box && source->type == CAIRO_PATTERN_TYPE_SURFACE) {
 	const cairo_surface_pattern_t *surf_pattern = 
 	    reinterpret_cast<const cairo_surface_pattern_t*>(source);
 	cairo_int_status_t rv = _cairo_d2d_try_fastblit(d2dsurf, surf_pattern->surface,
-						        &box, &source->matrix, clip, op);
+						        &box, &source->matrix, clip, op,
+                                                        source->filter);
 
 	if (rv != CAIRO_INT_STATUS_UNSUPPORTED) {
 	    return rv;
 	}
     }
 
     op = _cairo_d2d_simplify_operator(op, source);