[haiku-webkit-commits] r217 - in webkit/trunk/WebCore/platform/graphics: . haiku

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Thu, 25 Feb 2010 16:40:19 +0000

Author: stippi
Date: Thu Feb 25 16:40:19 2010
New Revision: 217
URL: http://mmlr.dyndns.org/changeset/217

Log:
* Introduce GraphicsContext::inTransparencyLayer(), like many other ports do it
  for themselves. Use this in Font::drawGlyphs() to decide which drawing mode
  is best suited. This allows us to use B_OP_OVER for the root layer (i.e. the
  common case) again.
* Implement drawRect() and drawEllipse() with more features, i.e. at least
  using gradients for the fill.
* Added some comments to using the high color also for the stroke color,
  which should overwrite the fill color. Didn't enable it yet, since more
  debugging is necessary.

Modified:
   webkit/trunk/WebCore/platform/graphics/GraphicsContext.h
   webkit/trunk/WebCore/platform/graphics/haiku/FontHaiku.cpp
   webkit/trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp

Modified: webkit/trunk/WebCore/platform/graphics/GraphicsContext.h
==============================================================================
--- webkit/trunk/WebCore/platform/graphics/GraphicsContext.h    Thu Feb 25 
15:33:01 2010        (r216)
+++ webkit/trunk/WebCore/platform/graphics/GraphicsContext.h    Thu Feb 25 
16:40:19 2010        (r217)
@@ -387,6 +387,7 @@
 #endif
 
 #if PLATFORM(HAIKU)
+        bool inTransparencyLayer() const;
         pattern getHaikuStrokeStyle();
 #endif
 

Modified: webkit/trunk/WebCore/platform/graphics/haiku/FontHaiku.cpp
==============================================================================
--- webkit/trunk/WebCore/platform/graphics/haiku/FontHaiku.cpp  Thu Feb 25 
15:33:01 2010        (r216)
+++ webkit/trunk/WebCore/platform/graphics/haiku/FontHaiku.cpp  Thu Feb 25 
16:40:19 2010        (r217)
@@ -52,11 +52,15 @@
 {
     BView* view = graphicsContext->platformContext();
 
+    rgb_color color = graphicsContext->fillColor();
     rgb_color oldColor = view->HighColor();
     drawing_mode oldMode = view->DrawingMode();
 
-    view->SetDrawingMode(B_OP_ALPHA);
-    view->SetHighColor(graphicsContext->fillColor());
+    if (color.alpha < 255 || graphicsContext->inTransparencyLayer())
+        view->SetDrawingMode(B_OP_ALPHA);
+    else if (oldMode != B_OP_OVER)
+        view->SetDrawingMode(B_OP_OVER);
+    view->SetHighColor(color);
     view->SetFont(font->platformData().font());
 
     GlyphBufferGlyph* glyphs = 
const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from));

Modified: webkit/trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp
==============================================================================
--- webkit/trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp       
Thu Feb 25 15:33:01 2010        (r216)
+++ webkit/trunk/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp       
Thu Feb 25 16:40:19 2010        (r217)
@@ -68,15 +68,6 @@
             , accumulatedOrigin(B_ORIGIN)
             , previous(0)
         {
-            strokeColor.red = 0;
-            strokeColor.green = 0;
-            strokeColor.blue = 0;
-            strokeColor.alpha = 0;
-
-            fillColor.red = 0;
-            fillColor.green = 0;
-            fillColor.blue = 0;
-            fillColor.alpha = 255;
         }
         Layer(Layer* previous)
             : view(0)
@@ -90,16 +81,6 @@
             , accumulatedOrigin(B_ORIGIN)
             , previous(previous)
         {
-            strokeColor.red = 0;
-            strokeColor.green = 0;
-            strokeColor.blue = 0;
-            strokeColor.alpha = 0;
-
-            fillColor.red = 0;
-            fillColor.green = 0;
-            fillColor.blue = 0;
-            fillColor.alpha = 255;
-
             BRegion parentClipping;
             previous->view->GetClippingRegion(&parentClipping);
             BRect frameInParent = parentClipping.Frame();
@@ -140,8 +121,6 @@
         BBitmap* bitmap;
         BRegion clipping;
         bool cippingSet;
-        rgb_color strokeColor;
-        rgb_color fillColor;
         uint8 globalAlpha;
         BShape* currentShape;
         BShape* clipShape;
@@ -247,6 +226,11 @@
         delete layer;
     }
 
+    bool inTransparencyLayer() const
+    {
+        return m_currentLayer->previous;
+    }
+
     Layer* m_currentLayer;
 };
 
@@ -301,9 +285,20 @@
     if (paintingDisabled())
         return;
 
-    // TODO: Should use fill + strokeRect().
-    m_data->view()->FillRect(rect);
-    if (strokeStyle() != NoStroke)
+    if (m_common->state.fillPattern || m_common->state.fillGradient || 
fillColor().alpha()) {
+//        TODO: What's this shadow business?
+        if (m_common->state.fillPattern)
+            notImplemented();
+        else if (m_common->state.fillGradient) {
+            BGradient* gradient = 
m_common->state.fillGradient->platformGradient();
+//            
gradient->SetTransform(m_common->state.fillGradient->gradientSpaceTransform());
+            m_data->view()->FillRect(rect, *gradient);
+        } else
+            m_data->view()->FillRect(rect);
+    }
+
+    // TODO: Support gradients
+    if (strokeStyle() != NoStroke && strokeThickness() > 0.0f && 
strokeColor().alpha())
         m_data->view()->StrokeRect(rect, getHaikuStrokeStyle());
 }
 
@@ -322,14 +317,26 @@
     if (paintingDisabled())
         return;
 
-    m_data->view()->FillEllipse(rect);
-    if (strokeStyle() != NoStroke)
+    if (m_common->state.fillPattern || m_common->state.fillGradient || 
fillColor().alpha()) {
+//        TODO: What's this shadow business?
+        if (m_common->state.fillPattern)
+            notImplemented();
+        else if (m_common->state.fillGradient) {
+            BGradient* gradient = 
m_common->state.fillGradient->platformGradient();
+//            
gradient->SetTransform(m_common->state.fillGradient->gradientSpaceTransform());
+            m_data->view()->FillEllipse(rect, *gradient);
+        } else
+            m_data->view()->FillEllipse(rect);
+    }
+
+    // TODO: Support gradients
+    if (strokeStyle() != NoStroke && strokeThickness() > 0.0f && 
strokeColor().alpha())
         m_data->view()->StrokeEllipse(rect, getHaikuStrokeStyle());
 }
 
 void GraphicsContext::strokeRect(const FloatRect& rect, float width)
 {
-    if (paintingDisabled())
+    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() 
<= 0.0f || !strokeColor().alpha())
         return;
 
     float oldSize = m_data->view()->PenSize();
@@ -881,9 +888,19 @@
     if (paintingDisabled())
         return;
 
+    // NOTE: In theory, we should be able to use the low color and
+    // return B_SOLID_LOW for the SolidStroke case in getHaikuStrokeStyle()
+    // below. More stuff needs to be fixed, though, it will for example
+    // prevent the text caret from rendering.
+//    m_data->view()->SetLowColor(color);
     m_data->view()->SetHighColor(color);
 }
 
+bool GraphicsContext::inTransparencyLayer() const
+{
+       return m_data->inTransparencyLayer();
+}
+
 pattern GraphicsContext::getHaikuStrokeStyle()
 {
     switch (strokeStyle()) {

Other related posts:

  • » [haiku-webkit-commits] r217 - in webkit/trunk/WebCore/platform/graphics: . haiku - webkit