| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/gtk/cairo_cached_surface.h" | 5 #include "chrome/browser/gtk/cairo_cached_surface.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 CairoCachedSurface::CairoCachedSurface() : pixbuf_(NULL), surface_(NULL) { | 10 CairoCachedSurface::CairoCachedSurface() : pixbuf_(NULL), surface_(NULL) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 if (!surface_) { | 48 if (!surface_) { |
| 49 // First time here since last UsePixbuf call. Generate the surface. | 49 // First time here since last UsePixbuf call. Generate the surface. |
| 50 cairo_surface_t* target = cairo_get_target(cr); | 50 cairo_surface_t* target = cairo_get_target(cr); |
| 51 surface_ = cairo_surface_create_similar( | 51 surface_ = cairo_surface_create_similar( |
| 52 target, | 52 target, |
| 53 CAIRO_CONTENT_COLOR_ALPHA, | 53 CAIRO_CONTENT_COLOR_ALPHA, |
| 54 gdk_pixbuf_get_width(pixbuf_), | 54 gdk_pixbuf_get_width(pixbuf_), |
| 55 gdk_pixbuf_get_height(pixbuf_)); | 55 gdk_pixbuf_get_height(pixbuf_)); |
| 56 | 56 |
| 57 DCHECK(surface_); | 57 DCHECK(surface_); |
| 58 DCHECK(cairo_surface_get_type(surface_) == CAIRO_SURFACE_TYPE_XLIB || | 58 #if !defined(NDEBUG) |
| 59 cairo_surface_get_type(surface_) == CAIRO_SURFACE_TYPE_XCB); | 59 int surface_type = cairo_surface_get_type(surface_); |
| 60 DCHECK(surface_type == CAIRO_SURFACE_TYPE_XLIB || |
| 61 surface_type == CAIRO_SURFACE_TYPE_XCB || |
| 62 surface_type == CAIRO_SURFACE_TYPE_IMAGE); |
| 63 #endif |
| 60 | 64 |
| 61 cairo_t* copy_cr = cairo_create(surface_); | 65 cairo_t* copy_cr = cairo_create(surface_); |
| 62 gdk_cairo_set_source_pixbuf(copy_cr, pixbuf_, 0, 0); | 66 gdk_cairo_set_source_pixbuf(copy_cr, pixbuf_, 0, 0); |
| 63 cairo_paint(copy_cr); | 67 cairo_paint(copy_cr); |
| 64 cairo_destroy(copy_cr); | 68 cairo_destroy(copy_cr); |
| 65 } | 69 } |
| 66 | 70 |
| 67 cairo_set_source_surface(cr, surface_, x, y); | 71 cairo_set_source_surface(cr, surface_, x, y); |
| 68 } | 72 } |
| OLD | NEW |