| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_ | 5 #ifndef UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_ |
| 6 #define UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_ | 6 #define UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ui/gfx/gfx_export.h" | 10 #include "ui/gfx/gfx_export.h" |
| 11 | 11 |
| 12 typedef struct _GdkDisplay GdkDisplay; | 12 typedef struct _GdkDisplay GdkDisplay; |
| 13 typedef struct _GdkPixbuf GdkPixbuf; | 13 typedef struct _GdkPixbuf GdkPixbuf; |
| 14 typedef struct _GtkWidget GtkWidget; | 14 typedef struct _GtkWidget GtkWidget; |
| 15 typedef struct _cairo cairo_t; | 15 typedef struct _cairo cairo_t; |
| 16 typedef struct _cairo_surface cairo_surface_t; | 16 typedef struct _cairo_surface cairo_surface_t; |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 | 19 |
| 20 // A helper class that takes a GdkPixbuf* and renders it to the screen. Unlike | 20 // A helper class that takes a GdkPixbuf* and renders it to the screen. Unlike |
| 21 // gdk_cairo_set_source_pixbuf(), CairoCachedSurface assumes that the pixbuf is | 21 // gdk_cairo_set_source_pixbuf(), CairoCachedSurface assumes that the pixbuf is |
| 22 // immutable after UsePixbuf() is called and can be sent to the display server | 22 // immutable after UsePixbuf() is called and can be sent to the display server |
| 23 // once. From then on, that cached version is used so we don't upload the same | 23 // once. From then on, that cached version is used so we don't upload the same |
| 24 // image each and every time we expose. | 24 // image each and every time we expose. |
| 25 // | 25 // |
| 26 // Most cached surfaces are owned by the GtkThemeService, which associates | 26 // Most cached surfaces are owned by the GtkThemeService, which associates |
| 27 // them with a certain XDisplay. Some users of surfaces (CustomDrawButtonBase, | 27 // them with a certain XDisplay. Some users of surfaces (CustomDrawButtonBase, |
| 28 // for example) own their surfaces instead since they interact with the | 28 // for example) own their surfaces instead since they interact with the |
| 29 // ResourceBundle instead of the GtkThemeService. | 29 // ResourceBundle instead of the GtkThemeService. |
| 30 class UI_EXPORT CairoCachedSurface { | 30 class GFX_EXPORT CairoCachedSurface { |
| 31 public: | 31 public: |
| 32 CairoCachedSurface(); | 32 CairoCachedSurface(); |
| 33 ~CairoCachedSurface(); | 33 ~CairoCachedSurface(); |
| 34 | 34 |
| 35 // Whether this CairoCachedSurface owns a GdkPixbuf. | 35 // Whether this CairoCachedSurface owns a GdkPixbuf. |
| 36 bool valid() const { | 36 bool valid() const { |
| 37 return pixbuf_; | 37 return pixbuf_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Delete all our data. | 40 // Delete all our data. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Our list of cached surfaces. 99% of the time, this will only contain a | 76 // Our list of cached surfaces. 99% of the time, this will only contain a |
| 77 // single entry. At most two. We need to get this right for multiple displays | 77 // single entry. At most two. We need to get this right for multiple displays |
| 78 // to work correct, since each GdkDisplay is a different display server. | 78 // to work correct, since each GdkDisplay is a different display server. |
| 79 mutable SurfaceVector surface_map_; | 79 mutable SurfaceVector surface_map_; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace gfx | 82 } // namespace gfx |
| 83 | 83 |
| 84 #endif // UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_ | 84 #endif // UI_GFX_IMAGE_CAIRO_CACHED_SURFACE_H_ |
| OLD | NEW |