2010-09-08 Nico Weber <thakis@chromium.org>
authorthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Sep 2010 13:02:16 +0000 (13:02 +0000)
committerthakis@chromium.org <thakis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Sep 2010 13:02:16 +0000 (13:02 +0000)
        Reviewed by Kenneth Russell.

        chromium/mac: Fix crash with compositor due to missing current NSGraphicsContext
        https://bugs.webkit.org/show_bug.cgi?id=45354

        * platform/graphics/chromium/ContentLayerChromium.cpp:
        (WebCore::ContentLayerChromium::updateContents): Set a current local context.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@66975 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

index 84c76b5..90bfb3a 100644 (file)
@@ -1,3 +1,13 @@
+2010-09-08  Nico Weber  <thakis@chromium.org>
+
+        Reviewed by Kenneth Russell.
+
+        chromium/mac: Fix crash with compositor due to missing current NSGraphicsContext
+        https://bugs.webkit.org/show_bug.cgi?id=45354
+
+        * platform/graphics/chromium/ContentLayerChromium.cpp:
+        (WebCore::ContentLayerChromium::updateContents): Set a current local context.
+
 2010-09-08  Justin Schuh  <jschuh@chromium.org>
 
         Reviewed by Nikolas Zimmermann.
index 974933d..5c8b869 100644 (file)
@@ -42,6 +42,8 @@
 #include "PlatformContextSkia.h"
 #include "skia/ext/platform_canvas.h"
 #elif PLATFORM(CG)
+#include "LocalCurrentGraphicsContext.h"
+
 #include <CoreGraphics/CGBitmapContext.h>
 #endif
 
@@ -152,12 +154,6 @@ void ContentLayerChromium::updateContents()
     IntSize requiredTextureSize;
     IntSize bitmapSize;
 
-#if PLATFORM(SKIA)
-    const SkBitmap* skiaBitmap = 0;
-    OwnPtr<skia::PlatformCanvas> canvas;
-    OwnPtr<PlatformContextSkia> skiaContext;
-    OwnPtr<GraphicsContext> graphicsContext;
-
     requiredTextureSize = m_bounds;
     IntRect boundsRect(IntPoint(0, 0), m_bounds);
 
@@ -171,6 +167,12 @@ void ContentLayerChromium::updateContents()
         dirtyRect.intersect(boundsRect);
     }
 
+#if PLATFORM(SKIA)
+    const SkBitmap* skiaBitmap = 0;
+    OwnPtr<skia::PlatformCanvas> canvas;
+    OwnPtr<PlatformContextSkia> skiaContext;
+    OwnPtr<GraphicsContext> graphicsContext;
+
     canvas.set(new skia::PlatformCanvas(dirtyRect.width(), dirtyRect.height(), false));
     skiaContext.set(new PlatformContextSkia(canvas.get()));
 
@@ -201,19 +203,6 @@ void ContentLayerChromium::updateContents()
         bitmapSize = IntSize(skiaBitmap->width(), skiaBitmap->height());
     }
 #elif PLATFORM(CG)
-    requiredTextureSize = m_bounds;
-    IntRect boundsRect(IntPoint(0, 0), m_bounds);
-
-    // If the texture needs to be reallocated then we must redraw the entire
-    // contents of the layer.
-    if (requiredTextureSize != m_allocatedTextureSize)
-        dirtyRect = boundsRect;
-    else {
-        // Clip the dirtyRect to the size of the layer to avoid drawing outside
-        // the bounds of the backing texture.
-        dirtyRect.intersect(boundsRect);
-    }
-
     Vector<uint8_t> tempVector;
     int rowBytes = 4 * dirtyRect.width();
     tempVector.resize(rowBytes * dirtyRect.height());
@@ -225,6 +214,7 @@ void ContentLayerChromium::updateContents()
                                                                      kCGImageAlphaPremultipliedLast));
 
     GraphicsContext graphicsContext(contextCG.get());
+    LocalCurrentGraphicsContext scopedNSGraphicsContext(&graphicsContext);
 
     // Translate the graphics contxt into the coordinate system of the dirty rect.
     graphicsContext.translate(-dirtyRect.x(), -dirtyRect.y());