Reviewed by Oliver.
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Feb 2008 03:38:04 +0000 (03:38 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Feb 2008 03:38:04 +0000 (03:38 +0000)
        Remove m_drawingContext and change m_data to m_imageBuffer

        * html/HTMLCanvasElement.cpp:
        (WebCore::HTMLCanvasElement::HTMLCanvasElement):
        (WebCore::HTMLCanvasElement::reset):
        (WebCore::HTMLCanvasElement::paint):
        (WebCore::HTMLCanvasElement::createImageBuffer):
        (WebCore::HTMLCanvasElement::buffer):
        (WebCore::HTMLCanvasElement::createPlatformImage):
        * html/HTMLCanvasElement.h:

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

WebCore/ChangeLog
WebCore/html/HTMLCanvasElement.cpp
WebCore/html/HTMLCanvasElement.h

index 0cae404c98e0f7455cefe079ae27c49e5f2e179b..5fcaca66374850c5f80701256a45d6b6120bc27e 100644 (file)
@@ -1,3 +1,18 @@
+2008-02-20  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Oliver.
+
+        Remove m_drawingContext and change m_data to m_imageBuffer
+
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::HTMLCanvasElement):
+        (WebCore::HTMLCanvasElement::reset):
+        (WebCore::HTMLCanvasElement::paint):
+        (WebCore::HTMLCanvasElement::createImageBuffer):
+        (WebCore::HTMLCanvasElement::buffer):
+        (WebCore::HTMLCanvasElement::createPlatformImage):
+        * html/HTMLCanvasElement.h:
+
 2008-02-20  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Sam.
index b4aade22ec80316446eafd808a83eb68094747a0..b8eb0c5960c8077bbc6d9553585e7b764ac859f3 100644 (file)
@@ -65,9 +65,7 @@ static const float maxCanvasArea = 32768 * 8192; // Maximum canvas area in CSS p
 HTMLCanvasElement::HTMLCanvasElement(Document* doc)
     : HTMLElement(canvasTag, doc)
     , m_size(defaultWidth, defaultHeight)
-    , m_createdDrawingContext(false)
-    , m_data()
-    , m_drawingContext(0)
+    , m_createdImageBuffer(false)
 {
 }
 
@@ -163,11 +161,9 @@ void HTMLCanvasElement::reset()
     IntSize oldSize = m_size;
     m_size = IntSize(w, h);
 
-    bool hadDrawingContext = m_createdDrawingContext;
-    m_createdDrawingContext = false;
-    m_data.set(0);
-    delete m_drawingContext;
-    m_drawingContext = 0;
+    bool hadImageBuffer = m_createdImageBuffer;
+    m_createdImageBuffer = false;
+    m_imageBuffer.clear();
     if (m_2DContext)
         m_2DContext->reset();
 
@@ -175,7 +171,7 @@ void HTMLCanvasElement::reset()
         if (m_rendererIsCanvas) {
             if (oldSize != m_size)
                 static_cast<RenderHTMLCanvas*>(ro)->canvasSizeChanged();
-            if (hadDrawingContext)
+            if (hadImageBuffer)
                 ro->repaint();
         }
 }
@@ -185,16 +181,16 @@ void HTMLCanvasElement::paint(GraphicsContext* p, const IntRect& r)
     if (p->paintingDisabled())
         return;
     
-    if (m_data)
-        p->paintBuffer(m_data.get(), r);
+    if (m_imageBuffer)
+        p->paintBuffer(m_imageBuffer.get(), r);
 }
 
-void HTMLCanvasElement::createDrawingContext() const
+void HTMLCanvasElement::createImageBuffer() const
 {
-    ASSERT(!m_createdDrawingContext);
-    ASSERT(!m_data);
+    ASSERT(!m_createdImageBuffer);
+    ASSERT(!m_imageBuffer);
 
-    m_createdDrawingContext = true;
+    m_createdImageBuffer = true;
 
     float unscaledWidth = width();
     float unscaledHeight = height();
@@ -207,7 +203,7 @@ void HTMLCanvasElement::createDrawingContext() const
 
     IntSize size(static_cast<unsigned>(wf), static_cast<unsigned>(hf));
 
-    m_data.set(ImageBuffer::create(size, false).release());
+    m_imageBuffer.set(ImageBuffer::create(size, false).release());
 }
 
 GraphicsContext* HTMLCanvasElement::drawingContext() const
@@ -217,9 +213,9 @@ GraphicsContext* HTMLCanvasElement::drawingContext() const
 
 ImageBuffer* HTMLCanvasElement::buffer() const
 {
-    if (!m_createdDrawingContext)
-        createDrawingContext();
-    return m_data.get();
+    if (!m_createdImageBuffer)
+        createImageBuffer();
+    return m_imageBuffer.get();
 }
 
 #if PLATFORM(CG)
@@ -243,25 +239,25 @@ CGImageRef HTMLCanvasElement::createPlatformImage() const
 
 QPixmap HTMLCanvasElement::createPlatformImage() const
 {
-    if (!m_data)
+    if (!m_imageBuffer)
         return QPixmap();
-    return *m_data->pixmap();
+    return *m_imageBuffer->pixmap();
 }
 
 #elif PLATFORM(CAIRO)
 
 cairo_surface_t* HTMLCanvasElement::createPlatformImage() const
 {
-    if (!m_data)
+    if (!m_imageBuffer)
         return 0;
 
     // Note that unlike CG, our returned image is not a copy or
     // copy-on-write, but the original. This is fine, since it is only
     // ever used as a source.
 
-    cairo_surface_flush(m_data->surface());
-    cairo_surface_reference(m_data->surface());
-    return m_data->surface();
+    cairo_surface_flush(m_imageBuffer->surface());
+    cairo_surface_reference(m_imageBuffer->surface());
+    return m_imageBuffer->surface();
 }
 
 #endif
index 348b860253d8fbeb967538928ed9cd9354d67f90..0836f090b89c85fd44d5991dba9f0b29ecf8ebae 100644 (file)
@@ -85,7 +85,7 @@ public:
 #endif
 
 private:
-    void createDrawingContext() const;
+    void createImageBuffer() const;
     void reset();
 
     bool m_rendererIsCanvas;
@@ -96,9 +96,9 @@ private:
     // FIXME: Web Applications 1.0 describes a security feature where we track
     // if we ever drew any images outside the domain, so we can disable toDataURL.
 
-    mutable bool m_createdDrawingContext;
-    mutable OwnPtr<ImageBuffer> m_data;
-    mutable GraphicsContext* m_drawingContext;
+    // m_createdImageBuffer means we tried to malloc the buffer.  We didn't necessarily get it.
+    mutable bool m_createdImageBuffer;
+    mutable OwnPtr<ImageBuffer> m_imageBuffer;
 };
 
 } //namespace