+
+ if( cachedIndex != -1 )
+ {
+ // Same url but border is different - use the existing texture
+ Data* data = new Data();
+ data->hash = hash;
+ data->url = url;
+ data->croppedWidth = mCache[ cachedIndex ]->croppedWidth;
+ data->croppedHeight = mCache[ cachedIndex ]->croppedHeight;
+
+ data->textureSet = mCache[ cachedIndex ]->textureSet;
+
+ NinePatchImage::StretchRanges stretchRangesX;
+ stretchRangesX.PushBack( Uint16Pair( border.left, data->croppedWidth - border.right ) );
+
+ NinePatchImage::StretchRanges stretchRangesY;
+ stretchRangesY.PushBack( Uint16Pair( border.top, data->croppedHeight - border.bottom ) );
+
+ data->stretchPixelsX = stretchRangesX;
+ data->stretchPixelsY = stretchRangesY;
+ data->border = border;
+
+ mCache.PushBack( data );
+
+ return mCache.Count(); // valid ids start from 1u
+ }
+