Bug 953334 - Clear the clip on the surface when we get a new DC. r=BenWa, a=bajaj
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Wed, 08 Jan 2014 16:02:22 -0500
changeset 169191 7fbaade4517365e85d36b8def11e27477dc35a8a
parent 169190 2f64f1f2c4c497bee46cee4e44345b54a853de2d
child 169192 fa25f54619152e1fe3125d302cdcaa7ae05756a2
push id4918
push userryanvm@gmail.com
push dateMon, 13 Jan 2014 16:23:15 +0000
treeherdermozilla-aurora@fa25f5461915 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenWa, bajaj
bugs953334
milestone28.0a2
Bug 953334 - Clear the clip on the surface when we get a new DC. r=BenWa, a=bajaj Currently we can think that we have a clip set on the DC when we actually don't. Calling _cairo_win32_surface_set_clip_region(NULL) clears this so that when we call it with the a region we will set it properly on the new DC that doesn't have the clip set on it.
gfx/cairo/cairo/src/cairo-win32-surface.c
layout/reftests/bugs/953334-win32-clipping-ref.html
layout/reftests/bugs/953334-win32-clipping.html
layout/reftests/bugs/reftest.list
--- a/gfx/cairo/cairo/src/cairo-win32-surface.c
+++ b/gfx/cairo/cairo/src/cairo-win32-surface.c
@@ -497,16 +497,26 @@ cairo_status_t
 	DeleteObject (surface->initial_clip_rgn);
 
     if (surface->font_subsets != NULL)
 	_cairo_scaled_font_subsets_destroy (surface->font_subsets);
 
     return CAIRO_STATUS_SUCCESS;
 }
 
+static void
+get_d3d9_dc_and_clear_clip (cairo_win32_surface_t *surface)
+{
+    IDirect3DSurface9_GetDC (surface->d3d9surface, &surface->dc);
+    // The DC that we get back from the surface will not have
+    // a clip so clear surface->clip_region so that we don't think we have
+    // one when we don't.
+    _cairo_win32_surface_set_clip_region (surface, NULL);
+}
+
 static cairo_status_t
 _cairo_win32_surface_d3d9_lock_rect (cairo_win32_surface_t  *surface,
 				   int                     x,
 				   int                     y,
 				   int                     width,
 				   int                     height,
 				   cairo_image_surface_t **local_out)
 {
@@ -516,31 +526,31 @@ static cairo_status_t
     RECT rectin = { x, y, x+width, y+height };
     D3DLOCKED_RECT rectout;
     HRESULT hr;
     hr = IDirect3DSurface9_ReleaseDC (surface->d3d9surface, surface->dc);
     hr = IDirect3DSurface9_LockRect (surface->d3d9surface,
 	                             &rectout, &rectin, 0);
     surface->dc = 0; // Don't use the DC when this is locked!
     if (hr) {
-        IDirect3DSurface9_GetDC (surface->d3d9surface, &surface->dc);
+	get_d3d9_dc_and_clear_clip (surface);
         return CAIRO_INT_STATUS_UNSUPPORTED;
     }
     local = cairo_image_surface_create_for_data (rectout.pBits,
 	                                         surface->format,
 						 width, height,
 						 rectout.Pitch);
     if (local == NULL) {
 	IDirect3DSurface9_UnlockRect (surface->d3d9surface);
-	IDirect3DSurface9_GetDC (surface->d3d9surface, &surface->dc);
+	get_d3d9_dc_and_clear_clip (surface);
         return CAIRO_INT_STATUS_UNSUPPORTED;
     }
     if (local->base.status) {
 	IDirect3DSurface9_UnlockRect (surface->d3d9surface);
-	IDirect3DSurface9_GetDC (surface->d3d9surface, &surface->dc);
+	get_d3d9_dc_and_clear_clip (surface);
         return local->base.status;
     }
 
     *local_out = local;
 
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -704,17 +714,17 @@ static void
 					   cairo_image_surface_t  *image,
 					   void                   *image_extra)
 {
     cairo_win32_surface_t *surface = abstract_surface;
     cairo_win32_surface_t *local = image_extra;
 
     if (local && local->d3d9surface) {
 	IDirect3DSurface9_UnlockRect (local->d3d9surface);
-	IDirect3DSurface9_GetDC (local->d3d9surface, &local->dc);
+	get_d3d9_dc_and_clear_clip (surface);
 	cairo_surface_destroy ((cairo_surface_t *)image);
     } else {
 	cairo_surface_destroy ((cairo_surface_t *)local);
     }
 }
 
 static cairo_status_t
 _cairo_win32_surface_acquire_dest_image (void                    *abstract_surface,
@@ -779,17 +789,17 @@ static void
     cairo_win32_surface_t *surface = abstract_surface;
     cairo_win32_surface_t *local = image_extra;
 
     if (!local)
 	return;
 
     if (local->d3d9surface) {
 	IDirect3DSurface9_UnlockRect (local->d3d9surface);
-	IDirect3DSurface9_GetDC (local->d3d9surface, &local->dc);
+	get_d3d9_dc_and_clear_clip (surface);
 	cairo_surface_destroy ((cairo_surface_t *)image);
     } else {
 
 	/* clear any clip that's currently set on the surface
 	   so that we can blit uninhibited. */
 	_cairo_win32_surface_set_clip_region (surface, NULL);
 
 	if (!BitBlt (surface->dc,
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/953334-win32-clipping-ref.html
@@ -0,0 +1,22 @@
+<style type="text/css">
+#descdiv{
+overflow: hidden;
+height: 60px;
+border: 1px solid red;
+}
+#descdiv p{
+height:30px;
+margin:0;
+/* The shadow of the text will be inside the overflow-hidden but the text it self will not.
+   This causes the text to be drawn even when it's outside of the clip*/
+text-shadow: #fff 1px -1px 2px;
+}
+
+</style>
+
+<div id="descdiv">
+<p class="um_desc">&nbsp;</p>
+<p class="um_desc">&nbsp;</p>
+<p class="um_desc">&nbsp;</p>
+</div>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/953334-win32-clipping.html
@@ -0,0 +1,22 @@
+<style type="text/css">
+#descdiv{
+overflow: hidden;
+height: 60px;
+border: 1px solid red;
+}
+#descdiv p{
+height:30px;
+margin:0;
+/* The shadow of the text will be inside the overflow-hidden but the text it self will not.
+   This causes the text to be drawn even when it's outside of the clip*/
+text-shadow: #fff 1px -1px 2px;
+}
+
+</style>
+
+<div id="descdiv">
+<p class="um_desc">&nbsp;</p>
+<p class="um_desc">&nbsp;</p>
+<p class="um_desc">sed diam nonummy nibh</p>
+</div>
+
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1783,9 +1783,10 @@ fuzzy-if(cocoaWidget,1,40) == 928607-1.h
 == 931464-1.html 931464-1-ref.html
 == 931853.html 931853-ref.html
 == 931853-quirks.html 931853-quirks-ref.html
 fuzzy-if(OSX==10.6,2,30) == 933264-1.html 933264-1-ref.html
 == 936670-1.svg 936670-1-ref.svg
 == 941940-1.html 941940-1-ref.html
 == 942017.html 942017-ref.html
 == 942672-1.html 942672-1-ref.html
+== 953334-win32-clipping.html 953334-win32-clipping-ref.html
 == 944291-1.html 944291-1-ref.html