Changeset 142297 in webkit
- Timestamp:
- Feb 8, 2013 9:58:11 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r142289 r142297 1 2013-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 1 28 2013-02-08 Harald Alvestrand <hta@google.com> 2 29 -
trunk/Source/WebCore/platform/graphics/clutter/GraphicsLayerActor.cpp
r142172 r142297 1 1 /* 2 * Copyright 2011, 2012 Collabora Limited2 * Copyright 2011, 2012, 2013 Collabora Limited 3 3 * Copyright (C) 2012 Intel Corporation. All rights reserved. 4 4 * … … 48 48 gboolean drawsContent; 49 49 50 float anchorX;51 float anchorY;52 float anchorZ;53 54 50 float scrollX; 55 51 float scrollY; … … 213 209 CLUTTER_ACTOR_CLASS(graphics_layer_actor_parent_class)->apply_transform(actor, matrix); 214 210 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 224 211 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 226 224 // CSS3 tranform-style can be changed on the fly, 227 225 // 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); 231 229 cogl_matrix_multiply(matrix, matrix, localMatrix); 232 cogl_matrix_translate(matrix, - pivotX, -pivotY, -priv->anchorZ);230 cogl_matrix_translate(matrix, -anchorX, -anchorY, -anchorZ); 233 231 cogl_matrix_free(localMatrix); 234 232 } … … 239 237 GraphicsLayerActor* graphicsLayer = GRAPHICS_LAYER_ACTOR(actor); 240 238 241 GList* list; 242 for (list = graphicsLayer->children; list; list = list->next) { 239 for (GList* list = graphicsLayer->children; list; list = list->next) { 243 240 ClutterActor* child = CLUTTER_ACTOR(list->data); 244 241 clutter_actor_paint(child); … … 248 245 static gboolean graphicsLayerActorDraw(ClutterCanvas* texture, cairo_t* cr, gint width, gint height, GraphicsLayerActor* layer) 249 246 { 250 ClutterActor* actor = CLUTTER_ACTOR(layer);251 252 247 if (!width || !height) 253 248 return FALSE; … … 267 262 268 263 if (priv->layerType == GraphicsLayerClutter::LayerTypeWebLayer) 269 drawLayerContents( actor, context);264 drawLayerContents(CLUTTER_ACTOR(layer), context); 270 265 271 266 return TRUE; … … 288 283 GraphicsLayerActorPrivate* priv = layer->priv; 289 284 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 } 300 294 return; 301 295 } 302 296 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. 309 298 int width = ceilf(clutter_actor_get_width(actor)); 310 299 int height = ceilf(clutter_actor_get_height(actor)); … … 326 315 return; 327 316 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)); 330 319 IntRect clip(0, 0, width, height); 331 320 … … 338 327 { 339 328 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; 343 330 344 331 return layer; … … 388 375 void graphicsLayerActorInvalidateRectangle(GraphicsLayerActor* layer, const FloatRect& dirtyRect) 389 376 { 390 ClutterContent* canvas; 391 canvas = clutter_actor_get_content(CLUTTER_ACTOR(layer)); 377 ClutterContent* canvas = clutter_actor_get_content(CLUTTER_ACTOR(layer)); 392 378 if (!canvas) 393 379 return; … … 399 385 void graphicsLayerActorSetTransform(GraphicsLayerActor* layer, const CoglMatrix* matrix) 400 386 { 401 GraphicsLayerActorPrivate* priv = layer->priv; 402 387 bool needToRedraw = false; 388 389 GraphicsLayerActorPrivate* priv = layer->priv; 403 390 if (priv->matrix) { 404 391 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 405 399 priv->matrix = 0; 400 401 if (needToRedraw) 406 402 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));419 403 } 420 404 421 405 void graphicsLayerActorSetAnchorPoint(GraphicsLayerActor* layer, float x, float y, float z) 422 406 { 423 GraphicsLayerActorPrivate* priv = layer->priv;424 425 priv->anchorX = x;426 priv->anchorY = y;427 priv->anchorZ = z;428 429 407 ClutterActor* actor = CLUTTER_ACTOR(layer); 430 408 clutter_actor_set_pivot_point(actor, x, y); … … 434 412 void graphicsLayerActorGetAnchorPoint(GraphicsLayerActor* layer, float* x, float* y, float* z) 435 413 { 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); 443 418 if (z) 444 *z = priv->anchorZ;419 *z = clutter_actor_get_pivot_point_z(actor); 445 420 } 446 421 447 422 void graphicsLayerActorSetScrollPosition(GraphicsLayerActor* layer, float x, float y) 448 423 { 449 GraphicsLayerActorPrivate* priv = layer->priv;450 451 424 if (x > 0 || y > 0) 452 425 return; 453 426 427 GraphicsLayerActorPrivate* priv = layer->priv; 454 428 priv->scrollX = x; 455 429 priv->scrollY = y; -
trunk/Source/WebCore/platform/graphics/clutter/PlatformClutterAnimation.h
r142094 r142297 162 162 #endif // USE(ACCELERATED_COMPOSITING) 163 163 164 #endif // PlatformC AAnimation_h164 #endif // PlatformClutterAnimation_h
Note: See TracChangeset
for help on using the changeset viewer.