Changeset 142297 in webkit


Ignore:
Timestamp:
Feb 8, 2013 9:58:11 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK][AC] GraphicsLayerActor code clean up after clutter version up.
https://bugs.webkit.org/show_bug.cgi?id=109304

Patch by ChangSeok Oh <ChangSeok Oh> on 2013-02-08
Reviewed by Gustavo Noronha Silva.

This patch cleans up GraphicsLayerActor functions by using new clutter apis
and makes existing functions simple & readable.

No new tests since no change in functionality

  • platform/graphics/clutter/GraphicsLayerActor.cpp:

(_GraphicsLayerActorPrivate):
(graphicsLayerActorApplyTransform):
(graphicsLayerActorPaint):
(graphicsLayerActorDraw):
(graphicsLayerActorUpdateTexture):
(drawLayerContents):
(graphicsLayerActorNew):
(graphicsLayerActorInvalidateRectangle):
(graphicsLayerActorSetTransform):
(graphicsLayerActorSetAnchorPoint):
(graphicsLayerActorGetAnchorPoint):
(graphicsLayerActorSetScrollPosition):

  • platform/graphics/clutter/PlatformClutterAnimation.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r142289 r142297  
     12013-02-08  ChangSeok Oh  <shivamidow@gmail.com>
     2
     3        [GTK][AC] GraphicsLayerActor code clean up after clutter version up.
     4        https://bugs.webkit.org/show_bug.cgi?id=109304
     5
     6        Reviewed by Gustavo Noronha Silva.
     7
     8        This patch cleans up GraphicsLayerActor functions by using new clutter apis
     9        and makes existing functions simple & readable.
     10
     11        No new tests since no change in functionality
     12
     13        * platform/graphics/clutter/GraphicsLayerActor.cpp:
     14        (_GraphicsLayerActorPrivate):
     15        (graphicsLayerActorApplyTransform):
     16        (graphicsLayerActorPaint):
     17        (graphicsLayerActorDraw):
     18        (graphicsLayerActorUpdateTexture):
     19        (drawLayerContents):
     20        (graphicsLayerActorNew):
     21        (graphicsLayerActorInvalidateRectangle):
     22        (graphicsLayerActorSetTransform):
     23        (graphicsLayerActorSetAnchorPoint):
     24        (graphicsLayerActorGetAnchorPoint):
     25        (graphicsLayerActorSetScrollPosition):
     26        * platform/graphics/clutter/PlatformClutterAnimation.h:
     27
    1282013-02-08  Harald Alvestrand  <hta@google.com>
    229
  • trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.cpp

    r142172 r142297  
    11/*
    2  * Copyright 2011, 2012 Collabora Limited
     2 * Copyright 2011, 2012, 2013 Collabora Limited
    33 * Copyright (C) 2012 Intel Corporation. All rights reserved.
    44 *
     
    4848    gboolean drawsContent;
    4949
    50     float anchorX;
    51     float anchorY;
    52     float anchorZ;
    53 
    5450    float scrollX;
    5551    float scrollY;
     
    213209    CLUTTER_ACTOR_CLASS(graphics_layer_actor_parent_class)->apply_transform(actor, matrix);
    214210
    215     float width = clutter_actor_get_width(actor);
    216     float height = clutter_actor_get_height(actor);
    217     if (width <= 1.0 || height <= 1.0)
    218         return;
    219 
    220     float pivotX, pivotY;
    221     pivotX = width * priv->anchorX;
    222     pivotY = height * priv->anchorY;
    223 
    224211    if (priv->matrix) {
    225         CoglMatrix* localMatrix;
     212        float width = 0, height = 0;
     213        clutter_actor_get_size(actor, &width, &height);
     214        if (width <= 1.0 || height <= 1.0)
     215            return;
     216
     217        // The pivot of actor is a normalized value, so we need an actual anchor position
     218        // in actor's local coordinate system for translating.
     219        float anchorX = 0, anchorY = 0, anchorZ = 0;
     220        graphicsLayerActorGetAnchorPoint(GRAPHICS_LAYER_ACTOR(actor), &anchorX, &anchorY, &anchorZ);
     221        anchorX *= width;
     222        anchorY *= height;
     223
    226224        // CSS3 tranform-style can be changed on the fly,
    227225        // so we have to copy priv->matrix in order to recover z-axis.
    228         localMatrix = cogl_matrix_copy(priv->matrix);
    229 
    230         cogl_matrix_translate(matrix, pivotX, pivotY, priv->anchorZ);
     226        CoglMatrix* localMatrix = cogl_matrix_copy(priv->matrix);
     227
     228        cogl_matrix_translate(matrix, anchorX, anchorY, anchorZ);
    231229        cogl_matrix_multiply(matrix, matrix, localMatrix);
    232         cogl_matrix_translate(matrix, -pivotX, -pivotY, -priv->anchorZ);
     230        cogl_matrix_translate(matrix, -anchorX, -anchorY, -anchorZ);
    233231        cogl_matrix_free(localMatrix);
    234232    }
     
    239237    GraphicsLayerActor* graphicsLayer = GRAPHICS_LAYER_ACTOR(actor);
    240238
    241     GList* list;
    242     for (list = graphicsLayer->children; list; list = list->next) {
     239    for (GList* list = graphicsLayer->children; list; list = list->next) {
    243240        ClutterActor* child = CLUTTER_ACTOR(list->data);
    244241        clutter_actor_paint(child);
     
    248245static gboolean graphicsLayerActorDraw(ClutterCanvas* texture, cairo_t* cr, gint width, gint height, GraphicsLayerActor* layer)
    249246{
    250     ClutterActor* actor = CLUTTER_ACTOR(layer);
    251 
    252247    if (!width || !height)
    253248        return FALSE;
     
    267262
    268263    if (priv->layerType == GraphicsLayerClutter::LayerTypeWebLayer)
    269         drawLayerContents(actor, context);
     264        drawLayerContents(CLUTTER_ACTOR(layer), context);
    270265
    271266    return TRUE;
     
    288283    GraphicsLayerActorPrivate* priv = layer->priv;
    289284    ASSERT(priv->layerType != GraphicsLayerClutter::LayerTypeVideoLayer);
    290     ClutterContent* canvas;
    291     canvas = clutter_actor_get_content(CLUTTER_ACTOR(layer));
    292 
    293     // Nothing needs a texture, remove the one we have, if any.
    294     if (!priv->drawsContent && !priv->surface) {
    295         if (!canvas)
    296             return;
    297 
    298         g_signal_handlers_disconnect_by_func(canvas, reinterpret_cast<void*>(graphicsLayerActorDraw), layer);
    299         g_object_unref(canvas);
     285
     286    ClutterActor* actor = CLUTTER_ACTOR(layer);
     287    ClutterContent* canvas = clutter_actor_get_content(actor);
     288    if (canvas) {
     289        // Nothing needs a texture, remove the one we have, if any.
     290        if (!priv->drawsContent && !priv->surface) {
     291            g_signal_handlers_disconnect_by_func(canvas, reinterpret_cast<void*>(graphicsLayerActorDraw), layer);
     292            g_object_unref(canvas);
     293        }
    300294        return;
    301295    }
    302296
    303     // We need a texture, but already have one!
    304     if (canvas)
    305         return;
    306 
    307     // We need a texture, so create it.
    308     ClutterActor* actor = CLUTTER_ACTOR(layer);
     297    // We should have a texture, so create one.
    309298    int width = ceilf(clutter_actor_get_width(actor));
    310299    int height = ceilf(clutter_actor_get_height(actor));
     
    326315        return;
    327316
    328     float width = clutter_actor_get_width(actor);
    329     float height = clutter_actor_get_height(actor);
     317    int width = static_cast<int>(clutter_actor_get_width(actor));
     318    int height = static_cast<int>(clutter_actor_get_height(actor));
    330319    IntRect clip(0, 0, width, height);
    331320
     
    338327{
    339328    GraphicsLayerActor* layer = GRAPHICS_LAYER_ACTOR(g_object_new(GRAPHICS_LAYER_TYPE_ACTOR, 0));
    340     GraphicsLayerActorPrivate* priv = layer->priv;
    341 
    342     priv->layerType = type;
     329    layer->priv->layerType = type;
    343330
    344331    return layer;
     
    388375void graphicsLayerActorInvalidateRectangle(GraphicsLayerActor* layer, const FloatRect& dirtyRect)
    389376{
    390     ClutterContent* canvas;
    391     canvas = clutter_actor_get_content(CLUTTER_ACTOR(layer));
     377    ClutterContent* canvas = clutter_actor_get_content(CLUTTER_ACTOR(layer));
    392378    if (!canvas)
    393379        return;
     
    399385void graphicsLayerActorSetTransform(GraphicsLayerActor* layer, const CoglMatrix* matrix)
    400386{
    401     GraphicsLayerActorPrivate* priv = layer->priv;
    402 
     387    bool needToRedraw = false;
     388
     389    GraphicsLayerActorPrivate* priv = layer->priv;
    403390    if (priv->matrix) {
    404391        cogl_matrix_free(priv->matrix);
     392        needToRedraw = true;
     393    }
     394
     395    if (!cogl_matrix_is_identity(matrix)) {
     396        priv->matrix = cogl_matrix_copy(matrix);
     397        needToRedraw = true;
     398    } else
    405399        priv->matrix = 0;
     400
     401    if (needToRedraw)
    406402        clutter_actor_queue_redraw(CLUTTER_ACTOR(layer));
    407     }
    408 
    409     CoglMatrix identity;
    410     cogl_matrix_init_identity(&identity);
    411     if (cogl_matrix_equal((CoglMatrix*)&identity, (CoglMatrix*)matrix))
    412         return;
    413 
    414     if (priv->matrix)
    415         cogl_matrix_free(priv->matrix);
    416 
    417     priv->matrix = cogl_matrix_copy(matrix);
    418     clutter_actor_queue_redraw(CLUTTER_ACTOR(layer));
    419403}
    420404
    421405void graphicsLayerActorSetAnchorPoint(GraphicsLayerActor* layer, float x, float y, float z)
    422406{
    423     GraphicsLayerActorPrivate* priv = layer->priv;
    424 
    425     priv->anchorX = x;
    426     priv->anchorY = y;
    427     priv->anchorZ = z;
    428 
    429407    ClutterActor* actor = CLUTTER_ACTOR(layer);
    430408    clutter_actor_set_pivot_point(actor, x, y);
     
    434412void graphicsLayerActorGetAnchorPoint(GraphicsLayerActor* layer, float* x, float* y, float* z)
    435413{
    436     GraphicsLayerActorPrivate* priv = layer->priv;
    437     if (x)
    438         *x = priv->anchorX;
    439 
    440     if (y)
    441         *y = priv->anchorY;
    442 
     414    ASSERT(x && y);
     415
     416    ClutterActor* actor = CLUTTER_ACTOR(layer);
     417    clutter_actor_get_pivot_point(actor, x, y);
    443418    if (z)
    444         *z = priv->anchorZ;
     419        *z = clutter_actor_get_pivot_point_z(actor);
    445420}
    446421
    447422void graphicsLayerActorSetScrollPosition(GraphicsLayerActor* layer, float x, float y)
    448423{
    449     GraphicsLayerActorPrivate* priv = layer->priv;
    450 
    451424    if (x > 0 || y > 0)
    452425        return;
    453426
     427    GraphicsLayerActorPrivate* priv = layer->priv;
    454428    priv->scrollX = x;
    455429    priv->scrollY = y;
  • trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.h

    r142094 r142297  
    162162#endif // USE(ACCELERATED_COMPOSITING)
    163163
    164 #endif // PlatformCAAnimation_h
     164#endif // PlatformClutterAnimation_h
Note: See TracChangeset for help on using the changeset viewer.