Author: lewing
Date: 2007-12-04 11:51:16 -0500 (Tue, 04 Dec 2007)
New Revision: 90697
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/media.cpp
trunk/moon/src/media.h
Log:
2007-12-03 Larry Ewing <[EMAIL PROTECTED]>
* src/media.cpp (Image::Render): use paint_with_alpha if opacity
is changing, use the old buffered alpha if it is not.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-12-04 16:47:24 UTC (rev 90696)
+++ trunk/moon/src/ChangeLog 2007-12-04 16:51:16 UTC (rev 90697)
@@ -1,3 +1,8 @@
+2007-12-03 Larry Ewing <[EMAIL PROTECTED]>
+
+ * src/media.cpp (Image::Render): use paint_with_alpha if opacity
+ is changing, use the old buffered alpha if it is not.
+
2007-12-04 Jb Evain <[EMAIL PROTECTED]>
* stylus.cpp|h: add stylus_info_get_current function.
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-12-04 16:47:24 UTC (rev 90696)
+++ trunk/moon/src/media.cpp 2007-12-04 16:51:16 UTC (rev 90697)
@@ -1125,6 +1125,7 @@
part_name(NULL),
pattern (NULL),
pattern_opacity (1.0),
+ opacity_stability_count (0),
brush (NULL)
{
}
@@ -1439,15 +1440,32 @@
double w = framework_element_get_width (this);
double h = framework_element_get_height (this);
+
+#define OPACITY_STABILITY_MAX 3
+
double render_opacity = GetTotalOpacity ();
double opacity = 1.0;
-#if USE_OPT_BUFFERED_IMAGE
- opacity = render_opacity;
- render_opacity = 1.0
-#endif
+ // Here we count the number of times we've been called with the
+ // same opacity and if it is greater than OPACITY_STABILITY_MAX we
+ // render the image to a temporary surface at that opacity, otherwise
+ // we render directly. The purpose here is to handle opacity animations
+ // with a fair amount of grace while avoiding the overhead of constantly
+ // adding another alpha pass when rendering stable scenes.
- if (!pattern || (floor (pattern_opacity * 255) != floor (opacity *
255))) {
+ if (render_opacity != pattern_opacity) {
+ opacity_stability_count = 0;
+ pattern_opacity = render_opacity;
+ } else {
+ opacity_stability_count ++;
+ if (opacity_stability_count >= OPACITY_STABILITY_MAX) {
+ opacity_stability_count = OPACITY_STABILITY_MAX;
+ opacity = render_opacity;
+ render_opacity = 1.0;
+ }
+ }
+
+ if (!pattern || (opacity_stability_count >= OPACITY_STABILITY_MAX &&
(floor (pattern_opacity * 255) != floor (opacity * 255)))) {
// don't share surfaces until they are of the correct type
if (pattern && !surface->xlib_surface_created) {
cairo_pattern_destroy (pattern);
Modified: trunk/moon/src/media.h
===================================================================
--- trunk/moon/src/media.h 2007-12-04 16:47:24 UTC (rev 90696)
+++ trunk/moon/src/media.h 2007-12-04 16:51:16 UTC (rev 90697)
@@ -96,6 +96,7 @@
// pattern caching
cairo_pattern_t *pattern;
double pattern_opacity;
+ int opacity_stability_count;
public:
Image ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches