diff options
Diffstat (limited to 'dw/style.cc')
-rw-r--r-- | dw/style.cc | 58 |
1 files changed, 39 insertions, 19 deletions
diff --git a/dw/style.cc b/dw/style.cc index 3f39a39e..5edb7047 100644 --- a/dw/style.cc +++ b/dw/style.cc @@ -258,8 +258,20 @@ container::typed::HashTable <StyleAttrs, Style> * Style::styleTable = Style::Style (StyleAttrs *attrs) { + DBG_OBJ_CREATE ("dw::core::style::Style"); + copyAttrs (attrs); + DBG_OBJ_ASSOC_CHILD (font); + DBG_OBJ_ASSOC_CHILD (color); + DBG_OBJ_ASSOC_CHILD (backgroundColor); + DBG_OBJ_ASSOC_CHILD (backgroundImage); + DBG_OBJ_ASSOC_CHILD (borderColor.top); + DBG_OBJ_ASSOC_CHILD (borderColor.bottom); + DBG_OBJ_ASSOC_CHILD (borderColor.left); + DBG_OBJ_ASSOC_CHILD (borderColor.right); + //DBG_OBJ_ASSOC_CHILD (x_tooltip); + refCount = 1; font->ref (); @@ -306,6 +318,8 @@ Style::~Style () styleTable->remove (this); totalRef--; + + DBG_OBJ_DELETE (); } void Style::copyAttrs (StyleAttrs *attrs) @@ -384,6 +398,7 @@ int FontAttrs::hashValue() Font::~Font () { free ((char*)name); + DBG_OBJ_DELETE (); } void Font::copyAttrs (FontAttrs *attrs) @@ -427,6 +442,7 @@ int ColorAttrs::hashValue() Color::~Color () { + DBG_OBJ_DELETE (); } int Color::shadeColor (int color, int d) @@ -510,6 +526,8 @@ void StyleImage::StyleImgRenderer::setBuffer (core::Imgbuf *buffer, bool resize) image->imgbufTiled = NULL; image->imgbufSrc = buffer; + DBG_OBJ_ASSOC (image, image->imgbufSrc); + if (image->imgbufSrc) { image->imgbufSrc->ref (); @@ -534,6 +552,8 @@ void StyleImage::StyleImgRenderer::setBuffer (core::Imgbuf *buffer, bool resize) image->imgbufSrc->createSimilarBuf (image->tilesX * image->imgbufSrc->getRootWidth(), image->tilesY * image->imgbufSrc->getRootHeight()); + + DBG_OBJ_ASSOC (image, image->imgbufTiled); } } } @@ -554,7 +574,7 @@ void StyleImage::StyleImgRenderer::drawRow (int row) int w = image->imgbufSrc->getRootWidth (); int h = image->imgbufSrc->getRootHeight (); - + for (int x = 0; x < image->tilesX; x++) for (int y = 0; y < image->tilesX; y++) image->imgbufSrc->copyTo (image->imgbufTiled, x * w, y * h, @@ -574,7 +594,7 @@ void StyleImage::StyleImgRenderer::fatal () StyleImage::StyleImage () { - //printf ("new StyleImage %p\n", this); + DBG_OBJ_CREATE ("dw::core::style::StyleImage"); refCount = 0; imgbufSrc = NULL; @@ -587,8 +607,6 @@ StyleImage::StyleImage () StyleImage::~StyleImage () { - //printf ("delete StyleImage %p\n", this); - if (imgbufSrc) imgbufSrc->unref (); if (imgbufTiled) @@ -596,6 +614,8 @@ StyleImage::~StyleImage () delete imgRendererDist; delete styleImgRenderer; + + DBG_OBJ_DELETE (); } void StyleImage::ExternalImgRenderer::setBuffer (core::Imgbuf *buffer, @@ -610,20 +630,20 @@ void StyleImage::ExternalImgRenderer::drawRow (int row) StyleImage *backgroundImage; if (readyToDraw () && (backgroundImage = getBackgroundImage ())) { // All single rows are drawn. - + Imgbuf *imgbuf = backgroundImage->getImgbufSrc(); int imgWidth = imgbuf->getRootWidth (); int imgHeight = imgbuf->getRootHeight (); - + int x, y, width, height; getBgArea (&x, &y, &width, &height); - + int xRef, yRef, widthRef, heightRef; getRefArea (&xRef, &yRef, &widthRef, &heightRef); - + bool repeatX, repeatY, doDraw; int origX, origY, tileX1, tileX2, tileY1, tileY2; - + calcBackgroundRelatedValues (backgroundImage, getBackgroundRepeat (), getBackgroundAttachment (), @@ -643,7 +663,7 @@ void StyleImage::ExternalImgRenderer::drawRow (int row) for (int tileY = tileY1; tileY <= tileY2; tileY++) { int x1 = misc::max (origX + tileX1 * imgWidth, x); int x2 = misc::min (origX + (tileX2 + 1) * imgWidth, x + width); - + int yt = origY + tileY * imgHeight + row; if (yt >= y && yt < y + height) draw (x1, yt, x2 - x1, 1); @@ -1204,7 +1224,7 @@ void drawBackground (View *view, Layout *layout, Rectangle *area, Color::SHADING_INVERSE : Color::SHADING_NORMAL, true, intersection.x, intersection.y, intersection.width, intersection.height); - + if (bgImage) drawBackgroundImage (view, style->backgroundImage, style->backgroundRepeat, @@ -1214,7 +1234,7 @@ void drawBackground (View *view, Layout *layout, Rectangle *area, intersection.x, intersection.y, intersection.width, intersection.height, xRef, yRef, widthRef, heightRef); - + } } } @@ -1233,7 +1253,7 @@ void drawBackgroundImage (View *view, StyleImage *backgroundImage, bool repeatX, repeatY, doDraw; int origX, origY, tileX1, tileX2, tileY1, tileY2; - + calcBackgroundRelatedValues (backgroundImage, backgroundRepeat, backgroundAttachment, backgroundPositionX, backgroundPositionY, x, y, width, height, @@ -1266,8 +1286,8 @@ void drawBackgroundImage (View *view, StyleImage *backgroundImage, int yt = origY + tileY * imgHeightS; int y1 = misc::max (yt, y); int y2 = misc::min (yt + imgHeightT, y + height); - - view->drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt, + + view->drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt, x2 - x1, y2 - y1); } } @@ -1293,7 +1313,7 @@ void calcBackgroundRelatedValues (StyleImage *backgroundImage, backgroundRepeat == BACKGROUND_REPEAT_X; *repeatY = backgroundRepeat == BACKGROUND_REPEAT || backgroundRepeat == BACKGROUND_REPEAT_Y; - + *origX = xRef + (isPerLength (backgroundPositionX) ? multiplyWithPerLength (widthRef - imgWidth, backgroundPositionX) : @@ -1302,7 +1322,7 @@ void calcBackgroundRelatedValues (StyleImage *backgroundImage, (isPerLength (backgroundPositionY) ? multiplyWithPerLength (heightRef - imgHeight, backgroundPositionY) : absLengthVal (backgroundPositionY)); - + *tileX1 = xDraw < *origX ? - (*origX - xDraw + imgWidth - 1) / imgWidth : (xDraw - *origX) / imgWidth; @@ -1315,7 +1335,7 @@ void calcBackgroundRelatedValues (StyleImage *backgroundImage, *tileY2 = *origY < yDraw + heightDraw ? (yDraw + heightDraw - *origY - 1) / imgHeight : - (*origY - (yDraw + heightDraw) + imgHeight - 1) / imgHeight; - + *doDraw = true; if (!*repeatX) { // Only center tile (tileX = 0) is drawn, ... @@ -1326,7 +1346,7 @@ void calcBackgroundRelatedValues (StyleImage *backgroundImage, // ... but is not visible. *doDraw = false; } - + if (!*repeatY) { // Analogue. if (*tileY1 <= 0 && *tileY2 >= 0) |