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