| OLD | NEW |
| 1 | 1 |
| 2 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #ifndef SKIA_EXT_CANVAS_PAINT_LINUX_H_ | 6 #ifndef SKIA_EXT_CANVAS_PAINT_LINUX_H_ |
| 7 #define SKIA_EXT_CANVAS_PAINT_LINUX_H_ | 7 #define SKIA_EXT_CANVAS_PAINT_LINUX_H_ |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 T::restoreToCount(1); | 42 T::restoreToCount(1); |
| 43 | 43 |
| 44 // Blit the dirty rect to the window. | 44 // Blit the dirty rect to the window. |
| 45 CHECK(window_); | 45 CHECK(window_); |
| 46 cairo_t* cr = gdk_cairo_create(window_); | 46 cairo_t* cr = gdk_cairo_create(window_); |
| 47 CHECK(cr); | 47 CHECK(cr); |
| 48 if (composite_alpha_) | 48 if (composite_alpha_) |
| 49 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 49 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 50 cairo_surface_t* source_surface = cairo_get_target(context_); | 50 cairo_surface_t* source_surface = cairo_get_target(context_); |
| 51 CHECK(source_surface); | 51 CHECK(source_surface); |
| 52 // Flush cairo's cache of the surface. |
| 53 cairo_surface_mark_dirty(source_surface); |
| 52 GdkRectangle bounds = rectangle(); | 54 GdkRectangle bounds = rectangle(); |
| 53 cairo_set_source_surface(cr, source_surface, bounds.x, bounds.y); | 55 cairo_set_source_surface(cr, source_surface, bounds.x, bounds.y); |
| 54 gdk_cairo_region(cr, region_); | 56 gdk_cairo_region(cr, region_); |
| 55 cairo_fill(cr); | 57 cairo_fill(cr); |
| 56 cairo_destroy(cr); | 58 cairo_destroy(cr); |
| 57 } | 59 } |
| 58 | 60 |
| 59 gdk_region_destroy(region_); | 61 gdk_region_destroy(region_); |
| 60 } | 62 } |
| 61 | 63 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 76 GdkRectangle bounds; | 78 GdkRectangle bounds; |
| 77 gdk_region_get_clipbox(region_, &bounds); | 79 gdk_region_get_clipbox(region_, &bounds); |
| 78 return bounds; | 80 return bounds; |
| 79 } | 81 } |
| 80 | 82 |
| 81 private: | 83 private: |
| 82 void init(bool opaque) { | 84 void init(bool opaque) { |
| 83 GdkRectangle bounds = rectangle(); | 85 GdkRectangle bounds = rectangle(); |
| 84 if (!T::initialize(bounds.width, bounds.height, opaque, NULL)) { | 86 if (!T::initialize(bounds.width, bounds.height, opaque, NULL)) { |
| 85 // Cause a deliberate crash; | 87 // Cause a deliberate crash; |
| 86 *(char*) 0 = 0; | 88 CHECK(false); |
| 87 } | 89 } |
| 88 | 90 |
| 89 // Need to translate so that the dirty region appears at the origin of the | 91 // Need to translate so that the dirty region appears at the origin of the |
| 90 // surface. | 92 // surface. |
| 91 T::translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y)); | 93 T::translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y)); |
| 92 | 94 |
| 93 context_ = T::getTopPlatformDevice().beginPlatformPaint(); | 95 context_ = T::getTopPlatformDevice().beginPlatformPaint(); |
| 94 } | 96 } |
| 95 | 97 |
| 96 cairo_t* context_; | 98 cairo_t* context_; |
| 97 GdkWindow* window_; | 99 GdkWindow* window_; |
| 98 GdkRegion* region_; | 100 GdkRegion* region_; |
| 99 // See description above setter. | 101 // See description above setter. |
| 100 bool composite_alpha_; | 102 bool composite_alpha_; |
| 101 | 103 |
| 102 // Disallow copy and assign. | 104 // Disallow copy and assign. |
| 103 CanvasPaintT(const CanvasPaintT&); | 105 CanvasPaintT(const CanvasPaintT&); |
| 104 CanvasPaintT& operator=(const CanvasPaintT&); | 106 CanvasPaintT& operator=(const CanvasPaintT&); |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 typedef CanvasPaintT<PlatformCanvas> PlatformCanvasPaint; | 109 typedef CanvasPaintT<PlatformCanvas> PlatformCanvasPaint; |
| 108 | 110 |
| 109 } // namespace skia | 111 } // namespace skia |
| 110 | 112 |
| 111 #endif // SKIA_EXT_CANVAS_PAINT_LINUX_H_ | 113 #endif // SKIA_EXT_CANVAS_PAINT_LINUX_H_ |
| OLD | NEW |