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/nine_box.h" | 5 #include "chrome/browser/gtk/nine_box.h" |
6 | 6 |
7 #include "base/gfx/gtk_util.h" | 7 #include "base/gfx/gtk_util.h" |
8 #include "base/gfx/point.h" | 8 #include "base/gfx/point.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 GDK_RGB_DITHER_NONE, 0, 0); // Dithering mode, x,y offsets. | 31 GDK_RGB_DITHER_NONE, 0, 0); // Dithering mode, x,y offsets. |
32 } | 32 } |
33 | 33 |
34 } // anonymous namespace | 34 } // anonymous namespace |
35 | 35 |
36 NineBox::NineBox(GdkPixbuf* images[9]) { | 36 NineBox::NineBox(GdkPixbuf* images[9]) { |
37 memcpy(images_, images, 9*sizeof(GdkPixbuf*)); | 37 memcpy(images_, images, 9*sizeof(GdkPixbuf*)); |
38 } | 38 } |
39 | 39 |
40 NineBox::~NineBox() { | 40 NineBox::~NineBox() { |
41 for (int i = 0; i < 9; ++i) { | |
42 if (images_[i]) | |
43 gdk_pixbuf_unref(images_[i]); | |
44 } | |
45 } | 41 } |
46 | 42 |
47 void NineBox::RenderToWidget(GtkWidget* dst) { | 43 void NineBox::RenderToWidget(GtkWidget* dst) { |
48 // TODO(evanm): this is stupid; it should just be implemented with SkBitmaps | 44 // TODO(evanm): this is stupid; it should just be implemented with SkBitmaps |
49 // and convert to a GdkPixbuf at the last second. | 45 // and convert to a GdkPixbuf at the last second. |
50 | 46 |
51 int dst_width = dst->allocation.width; | 47 int dst_width = dst->allocation.width; |
52 int dst_height = dst->allocation.height; | 48 int dst_height = dst->allocation.height; |
53 | 49 |
54 // This function paints one row at a time. | 50 // This function paints one row at a time. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 DCHECK(dx == 0 || dy == 0); | 128 DCHECK(dx == 0 || dy == 0); |
133 | 129 |
134 for (int x = x1, y = y1; x < x2 || y < y2; x += dx, y += dy) { | 130 for (int x = x1, y = y1; x < x2 || y < y2; x += dx, y += dy) { |
135 gdk_draw_pixbuf(dst->window, gc, src, 0, 0, | 131 gdk_draw_pixbuf(dst->window, gc, src, 0, 0, |
136 offset.x() + x, offset.y() + y, | 132 offset.x() + x, offset.y() + y, |
137 dx ? std::min(src_width, dst_width - x) : src_width, | 133 dx ? std::min(src_width, dst_width - x) : src_width, |
138 dy ? std::min(src_height, dst_height - y) : src_height, | 134 dy ? std::min(src_height, dst_height - y) : src_height, |
139 GDK_RGB_DITHER_NONE, 0, 0); | 135 GDK_RGB_DITHER_NONE, 0, 0); |
140 } | 136 } |
141 } | 137 } |
OLD | NEW |