Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Unified Diff: ui/gfx/image/image.cc

Issue 8769017: GTK: Move CairoCachedSurface from being owned by GtkThemeService to gfx::Image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/image/image.cc
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index 2ba2eba203349c389d491da3311398c8a28e59be..b6289be1f70ac590dce2ce8d172ac691f9d549b5 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -15,6 +15,7 @@
#include <glib-object.h>
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/gtk_util.h"
+#include "ui/gfx/image/cairo_cached_surface.h"
#elif defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#include "skia/ext/skia_utils_mac.h"
@@ -43,6 +44,7 @@ const SkBitmap* GdkPixbufToSkBitmap(GdkPixbuf* pixbuf) {
class ImageRepSkia;
class ImageRepGdk;
class ImageRepCocoa;
+class ImageRepCairoCached;
Robert Sesek 2011/12/01 19:30:35 nit: put below ImageRepGdk
// An ImageRep is the object that holds the backing memory for an Image. Each
// RepresentationType has an ImageRep subclass that is responsible for freeing
@@ -67,6 +69,11 @@ class ImageRep {
CHECK_EQ(type_, Image::kImageRepGdk);
return reinterpret_cast<ImageRepGdk*>(this);
}
+
+ ImageRepCairoCached* AsImageRepCairo() {
+ CHECK_EQ(type_, Image::kImageRepCairoCache);
+ return reinterpret_cast<ImageRepCairoCached*>(this);
+ }
#endif
#if defined(OS_MACOSX)
@@ -133,6 +140,29 @@ class ImageRepGdk : public ImageRep {
DISALLOW_COPY_AND_ASSIGN(ImageRepGdk);
};
+
+// Represents data that lives on the display server instead of in the client.
+class ImageRepCairoCached : public ImageRep {
+ public:
+ explicit ImageRepCairoCached(GdkPixbuf* pixbuf)
+ : ImageRep(Image::kImageRepCairoCache),
+ cairo_cache_(new CairoCachedSurface) {
+ CHECK(pixbuf);
+ cairo_cache_->UsePixbuf(pixbuf);
+ }
+
+ virtual ~ImageRepCairoCached() {
+ delete cairo_cache_;
+ }
+
+ CairoCachedSurface* surface() const { return cairo_cache_; }
+
+ private:
+ CairoCachedSurface* cairo_cache_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImageRepCairoCached);
+};
+
Robert Sesek 2011/12/01 19:30:35 nit: remove blank line
#endif
Robert Sesek 2011/12/01 19:30:35 // defined(TOOLKIT_USES_GTK)
#if defined(OS_MACOSX)
@@ -244,6 +274,11 @@ GdkPixbuf* Image::ToGdkPixbuf() const {
internal::ImageRep* rep = GetRepresentation(Image::kImageRepGdk);
return rep->AsImageRepGdk()->pixbuf();
}
+
+CairoCachedSurface* const Image::ToCairo() const {
+ internal::ImageRep* rep = GetRepresentation(Image::kImageRepCairoCache);
+ return rep->AsImageRepCairo()->surface();
+}
#endif
#if defined(OS_MACOSX)
@@ -361,6 +396,11 @@ internal::ImageRep* Image::GetRepresentation(
if (rep_type == Image::kImageRepGdk) {
GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(skia_rep->bitmap());
native_rep = new internal::ImageRepGdk(pixbuf);
+ } else if (rep_type == Image::kImageRepCairoCache) {
+ // Send the data that we have in process right now to the display server.
+ internal::ImageRep* rep = GetRepresentation(Image::kImageRepGdk);
+ native_rep = new internal::ImageRepCairoCached(
+ rep->AsImageRepGdk()->pixbuf());
}
#elif defined(OS_MACOSX)
if (rep_type == Image::kImageRepCocoa) {
« ui/gfx/image/image.h ('K') | « ui/gfx/image/image.h ('k') | ui/gfx/image/image_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698