| Index: ui/gfx/image/cairo_cached_surface.h
|
| diff --git a/chrome/browser/ui/gtk/cairo_cached_surface.h b/ui/gfx/image/cairo_cached_surface.h
|
| similarity index 62%
|
| rename from chrome/browser/ui/gtk/cairo_cached_surface.h
|
| rename to ui/gfx/image/cairo_cached_surface.h
|
| index eb481e84cde2d3bbdcba797df23b2de091facb3f..2be63f3f119a373b9a7283f55af746d2569ce5e0 100644
|
| --- a/chrome/browser/ui/gtk/cairo_cached_surface.h
|
| +++ b/ui/gfx/image/cairo_cached_surface.h
|
| @@ -2,17 +2,25 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_UI_GTK_CAIRO_CACHED_SURFACE_H_
|
| -#define CHROME_BROWSER_UI_GTK_CAIRO_CACHED_SURFACE_H_
|
| +#ifndef UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_
|
| +#define UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_
|
| #pragma once
|
|
|
| +#include <vector>
|
| +
|
| +#include "ui/base/ui_export.h"
|
| +
|
| +typedef struct _GdkDisplay GdkDisplay;
|
| typedef struct _GdkPixbuf GdkPixbuf;
|
| +typedef struct _GtkWidget GtkWidget;
|
| typedef struct _cairo cairo_t;
|
| typedef struct _cairo_surface cairo_surface_t;
|
|
|
| +namespace gfx {
|
| +
|
| // A helper class that takes a GdkPixbuf* and renders it to the screen. Unlike
|
| // gdk_cairo_set_source_pixbuf(), CairoCachedSurface assumes that the pixbuf is
|
| -// immutable after UsePixbuf() is called and can be sent to the X server
|
| +// immutable after UsePixbuf() is called and can be sent to the display server
|
| // once. From then on, that cached version is used so we don't upload the same
|
| // image each and every time we expose.
|
| //
|
| @@ -20,7 +28,7 @@ typedef struct _cairo_surface cairo_surface_t;
|
| // them with a certain XDisplay. Some users of surfaces (CustomDrawButtonBase,
|
| // for example) own their surfaces instead since they interact with the
|
| // ResourceBundle instead of the GtkThemeService.
|
| -class CairoCachedSurface {
|
| +class UI_EXPORT CairoCachedSurface {
|
| public:
|
| CairoCachedSurface();
|
| ~CairoCachedSurface();
|
| @@ -45,26 +53,33 @@ class CairoCachedSurface {
|
|
|
| // Sets our pixbuf as the active surface starting at (x, y), uploading it in
|
| // case we don't have an X backed surface cached.
|
| - void SetSource(cairo_t* cr, int x, int y);
|
| + void SetSource(cairo_t* cr, GtkWidget* widget, int x, int y) const;
|
| + void SetSource(cairo_t* cr, GdkDisplay* display, int x, int y) const;
|
|
|
| // Performs a mask operation, using this surface as the alpha channel.
|
| - void MaskSource(cairo_t* cr, int x, int y);
|
| + void MaskSource(cairo_t* cr, GtkWidget* widget, int x, int y) const;
|
| + void MaskSource(cairo_t* cr, GdkDisplay* display, int x, int y) const;
|
|
|
| // Raw access to the pixbuf. May be NULL. Used for a few gdk operations
|
| // regarding window shaping.
|
| GdkPixbuf* pixbuf() { return pixbuf_; }
|
|
|
| private:
|
| - // Makes sure |surface_| is a valid thing that lives on the X server,
|
| - // uploading it if necessary.
|
| - void EnsureSurfaceValid(cairo_t* cr);
|
| + typedef std::vector<std::pair<GdkDisplay*, cairo_surface_t*> > SurfaceVector;
|
| +
|
| + // Returns a surface . Caches results so only one copy of the image data
|
| + // lives on the display server.
|
| + cairo_surface_t* GetSurfaceFor(cairo_t* cr, GdkDisplay* display) const;
|
|
|
| // The source pixbuf.
|
| GdkPixbuf* pixbuf_;
|
|
|
| - // Our cached surface. This should be a xlib surface so the data lives on the
|
| - // server instead of on the client.
|
| - cairo_surface_t* surface_;
|
| + // Our list of cached surfaces. 99% of the time, this will only contain a
|
| + // single entry. At most two. We need to get this right for multiple displays
|
| + // to work correct, since each GdkDisplay is a different display server.
|
| + mutable SurfaceVector surface_map_;
|
| };
|
|
|
| -#endif // CHROME_BROWSER_UI_GTK_CAIRO_CACHED_SURFACE_H_
|
| +} // namespace gfx
|
| +
|
| +#endif // UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_
|
|
|