Back to index

unity  6.0.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
UnityDialogShadeTexture Class Reference

#include <unitydialog.h>

List of all members.

Public Member Functions

void render (float alpha)
void render ()
const GLTexture::List & texture ()
 UnityDialogShadeTexture ()
 ~UnityDialogShadeTexture ()

Static Public Member Functions

static UnityDialogShadeTexturecreate ()
static void onThemeChanged (GObject *obj, GParamSpec *pspec, gpointer data)

Private Member Functions

void clear ()
void destroy ()
void context ()

Private Attributes

Pixmap mPixmap
GLTexture::List mTexture
cairo_surface_t * mSurface
cairo_t * mCairo
Damage mDamage
GtkWidget * mOffscreenContainer
char * mThemeName
GtkStyle * mStyle
float mAlpha

Detailed Description

Definition at line 114 of file unitydialog.h.


Constructor & Destructor Documentation

Definition at line 104 of file unitydialog.cpp.

                                                 :
  mPixmap(None),
  mTexture(0),
  mSurface(NULL),
  mCairo(NULL),
  mDamage(None)
{
  mOffscreenContainer = gtk_offscreen_window_new();
  gtk_widget_set_name(mOffscreenContainer, "UnityPanelWidget");
  gtk_style_context_add_class(gtk_widget_get_style_context(mOffscreenContainer),
                              "menubar");
  gtk_widget_set_size_request(mOffscreenContainer, 100, 24);
  gtk_widget_show_all(mOffscreenContainer);

  g_signal_connect(gtk_settings_get_default(), "notify::gtk-theme-name",
                   G_CALLBACK(UnityDialogShadeTexture::onThemeChanged), this);

  g_object_get(gtk_settings_get_default(), "gtk-theme-name", &mThemeName, NULL);
  mStyle = gtk_widget_get_style(mOffscreenContainer);

  context();
}

Here is the call graph for this function:

Definition at line 127 of file unitydialog.cpp.

{
  gtk_widget_destroy(mOffscreenContainer);
  g_free(mThemeName);

  destroy();
}

Here is the call graph for this function:


Member Function Documentation

void UnityDialogShadeTexture::clear ( ) [private]

Definition at line 156 of file unitydialog.cpp.

{
  if (mCairo)
  {
    cairo_save(mCairo);
    cairo_set_operator(mCairo, CAIRO_OPERATOR_CLEAR);
    cairo_paint(mCairo);
    cairo_restore(mCairo);
  }
}

Here is the caller graph for this function:

Definition at line 168 of file unitydialog.cpp.

{
  if (!mCairo)
  {
    Screen*      xScreen;
    XRenderPictFormat* format;
    int     w, h;

    xScreen = ScreenOfDisplay(screen->dpy(), screen->screenNum());

    format = XRenderFindStandardFormat(screen->dpy(),
                                       PictStandardARGB32);

    w = 1;
    h = 1;

    mPixmap = XCreatePixmap(screen->dpy(), screen->root(), w, h, 32);

    mTexture = GLTexture::bindPixmapToTexture(mPixmap, w, h, 32);

    if (mTexture.empty())
    {
      compLogMessage("unitydialog", CompLogLevelError,
                     "Couldn't bind pixmap 0x%x to texture",
                     (int) mPixmap);

      XFreePixmap(screen->dpy(), mPixmap);

      return;
    }

    mDamage = XDamageCreate(screen->dpy(), mPixmap,
                            XDamageReportRawRectangles);

    mSurface =
      cairo_xlib_surface_create_with_xrender_format(screen->dpy(),
                                                    mPixmap, xScreen,
                                                    format, w, h);

    if (!mSurface)
    {
      compLogMessage("unitydialog", CompLogLevelError, "Couldn't create surface");

      XFreePixmap(screen->dpy(), mPixmap);
      XDamageDestroy(screen->dpy(), mDamage);
      mTexture.clear();

      return;
    }

    mCairo = cairo_create(mSurface);

    if (!mCairo)
    {
      compLogMessage("unitydialog", CompLogLevelError, "Couldn't create cairo context");

      cairo_surface_destroy(mSurface);
      XFreePixmap(screen->dpy(), mPixmap);
      XDamageDestroy(screen->dpy(), mDamage);
      mTexture.clear();
    }
  }
}

Here is the caller graph for this function:

Definition at line 136 of file unitydialog.cpp.

{
  if (mPixmap)
  {
    XFreePixmap(screen->dpy(), mPixmap);
    mPixmap = None;
  }
  if (mSurface)
  {
    cairo_surface_destroy(mSurface);
    mSurface = NULL;
  }
  if (mCairo)
  {
    cairo_destroy(mCairo);
    mCairo = NULL;
  }
}

Here is the caller graph for this function:

void UnityDialogShadeTexture::onThemeChanged ( GObject *  obj,
GParamSpec *  pspec,
gpointer  data 
) [static]

Definition at line 260 of file unitydialog.cpp.

{
  UnityDialogShadeTexture* self = static_cast<UnityDialogShadeTexture*>(data);

  g_object_get(gtk_settings_get_default(), "gtk-theme-name", &self->mThemeName, NULL);
  self->mStyle = gtk_widget_get_style(self->mOffscreenContainer);

  self->render();
}

Here is the caller graph for this function:

void UnityDialogShadeTexture::render ( float  alpha)

Definition at line 233 of file unitydialog.cpp.

{
  float divisorMask = 0xffff;
  mAlpha = alpha;

  clear();

  cairo_set_line_width(mCairo, 2);
  cairo_set_source_rgba(mCairo,
                        (mStyle->bg[1].red / divisorMask),
                        (mStyle->bg[1].green / divisorMask),
                        (mStyle->bg[1].blue / divisorMask),
                        (alpha));

  cairo_move_to(mCairo, 0, 0);
  cairo_rectangle(mCairo, 0, 0, 1, 1);

  cairo_fill(mCairo);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 254 of file unitydialog.cpp.

{
  render(mAlpha);
}
const GLTexture::List & UnityDialogShadeTexture::texture ( )

Definition at line 273 of file unitydialog.cpp.

{
  return mTexture;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 150 of file unitydialog.h.

cairo_t* UnityDialogShadeTexture::mCairo [private]

Definition at line 143 of file unitydialog.h.

Definition at line 144 of file unitydialog.h.

Definition at line 146 of file unitydialog.h.

Definition at line 140 of file unitydialog.h.

GtkStyle* UnityDialogShadeTexture::mStyle [private]

Definition at line 148 of file unitydialog.h.

cairo_surface_t* UnityDialogShadeTexture::mSurface [private]

Definition at line 142 of file unitydialog.h.

GLTexture::List UnityDialogShadeTexture::mTexture [private]

Definition at line 141 of file unitydialog.h.

Definition at line 147 of file unitydialog.h.


The documentation for this class was generated from the following files: