@@ -27,6 +27,14 @@ acgraph.vector.Shape = function() {
2727 */
2828 this . stroke_ = 'black' ;
2929
30+ /**
31+ * If the fill or stroke needs update on DATA invalidation.
32+ * 0 - no need, 1 - fill needs to be update, 2 - stroke, 3 - both.
33+ * @type {number }
34+ * @private
35+ */
36+ this . boundsAffectedColors_ = 0 ;
37+
3038 goog . base ( this ) ;
3139} ;
3240goog . inherits ( acgraph . vector . Shape , acgraph . vector . Element ) ;
@@ -73,7 +81,7 @@ acgraph.vector.Shape.prototype.fill = function(opt_fillOrColorOrKeys, opt_opacit
7381 // TODO(Anton Saukh): comparison must be more complex here
7482 if ( this . fill_ != newFill ) {
7583 this . fill_ = newFill ;
76- // Flag to show that fill changed
84+ this . boundsAffectedColors_ = ( this . boundsAffectedColors_ & 2 ) | ! ! ( newFill [ 'mode' ] || newFill [ 'src' ] ) ;
7785 this . setDirtyState ( acgraph . vector . Element . DirtyState . FILL ) ;
7886 }
7987 return this ;
@@ -98,7 +106,7 @@ acgraph.vector.Shape.prototype.stroke = function(opt_strokeOrFill, opt_thickness
98106 // TODO(Anton Saukh): comparison must be more complex here
99107 if ( this . stroke_ != newStroke ) {
100108 this . stroke_ = /** @type {acgraph.vector.Stroke } */ ( newStroke ) ;
101- // set flag that stroke has changed
109+ this . boundsAffectedColors_ = ( this . boundsAffectedColors_ & 1 ) | ( newStroke [ 'mode' ] << 1 ) ;
102110 this . setDirtyState ( acgraph . vector . Element . DirtyState . STROKE ) ;
103111 }
104112 return this ;
@@ -138,6 +146,13 @@ acgraph.vector.Shape.prototype.strokeThickness = function(opt_value) {
138146//----------------------------------------------------------------------------------------------------------------------
139147/** @inheritDoc */
140148acgraph . vector . Shape . prototype . renderInternal = function ( ) {
149+ if ( this . boundsAffectedColors_ && this . hasDirtyState ( acgraph . vector . Element . DirtyState . DATA ) ) {
150+ if ( ! ! ( this . boundsAffectedColors_ & 1 ) )
151+ this . setDirtyState ( acgraph . vector . Element . DirtyState . FILL ) ;
152+ if ( ! ! ( this . boundsAffectedColors_ & 2 ) )
153+ this . setDirtyState ( acgraph . vector . Element . DirtyState . STROKE ) ;
154+ }
155+
141156 goog . base ( this , 'renderInternal' ) ;
142157
143158 // Apply stroke and fill settings if they were changed
0 commit comments