[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.1/kdelibs/khtml
From:       Harri Porten <porten () kde ! org>
Date:       2008-11-04 21:52:11
Message-ID: 1225835531.333189.25450.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 880185 by porten:

Merged revision 880184:
Implement createImageData() canvas function.

 M  +9 -0      ecma/kjs_context2d.cpp  
 M  +1 -1      ecma/kjs_context2d.h  
 M  +16 -0     html/html_canvasimpl.cpp  
 M  +1 -0      html/html_canvasimpl.h  


--- branches/KDE/4.1/kdelibs/khtml/ecma/kjs_context2d.cpp #880184:880185
@@ -121,6 +121,7 @@
    # pixel ops.
    getImageData             Context2D::GetImageData                DontDelete|Function 4
    putImageData             Context2D::PutImageData                DontDelete|Function 3
+   createImageData          Context2D::CreateImageData             DontDelete|Function 2
    @end
 */
 
@@ -473,6 +474,14 @@
         ctx->putImageData(id.get(), args[1]->toFloat(exec), args[2]->toFloat(exec), exception);
         break;
     }
+    case Context2D::CreateImageData: {
+        KJS_REQUIRE_ARGS(2);
+        KJS_CHECK_FLOAT_ARGS(0, 1);
+        CanvasImageDataImpl* id = ctx->createImageData(args[0]->toFloat(exec),
+                                                       args[1]->toFloat(exec),
+                                                       exception);
+        return getWrapper<CanvasImageData>(exec, id);
+    }
 
     }
 
--- branches/KDE/4.1/kdelibs/khtml/ecma/kjs_context2d.h #880184:880185
@@ -105,7 +105,7 @@
         BeginPath, ClosePath, MoveTo, LineTo, QuadraticCurveTo, BezierCurveTo, ArcTo, Rect, Arc,
         Fill, Stroke, Clip, IsPointInPath,        // paths
         DrawImage,  // do we want backwards compat for drawImageFromRect?
-        GetImageData, PutImageData // pixel ops. ewww.
+        GetImageData, PutImageData, CreateImageData // pixel ops. ewww.
     };
   };
 
--- branches/KDE/4.1/kdelibs/khtml/html/html_canvasimpl.cpp #880184:880185
@@ -1584,4 +1584,20 @@
     p.drawImage(x, y, id->data);
 }
 
+CanvasImageDataImpl* CanvasContext2DImpl::createImageData(float sw, float sh, int& exceptionCode)
+{
+    int w = qRound(qAbs(sw));
+    int h = qRound(qAbs(sh));
+
+    if (w == 0 || h == 0) {
+        exceptionCode = DOMException::INDEX_SIZE_ERR;
+        return 0;
+    }
+
+    CanvasImageDataImpl* id = new CanvasImageDataImpl(w, h);
+    id->data.fill(Qt::transparent);
+
+    return id;
+}
+
 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;
--- branches/KDE/4.1/kdelibs/khtml/html/html_canvasimpl.h #880184:880185
@@ -282,6 +282,7 @@
     // Pixel ops
     CanvasImageDataImpl* getImageData(float sx, float sy, float sw, float sh, int& exceptionCode);
     void putImageData(CanvasImageDataImpl* data, float dx, float dy, int& exceptionCode);
+    CanvasImageDataImpl* createImageData(float sw, float sh, int& exceptionCode);
 
 private:
     friend class HTMLCanvasElementImpl;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic