OLD | NEW |
1 // Copyright (c) 2012 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 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
8 #include "ui/gfx/canvas_skia_paint.h" | 8 #include "ui/gfx/canvas_skia_paint.h" |
9 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 gdk_cairo_region(cr, region_); | 45 gdk_cairo_region(cr, region_); |
46 cairo_fill(cr); | 46 cairo_fill(cr); |
47 cairo_destroy(cr); | 47 cairo_destroy(cr); |
48 } | 48 } |
49 | 49 |
50 gdk_region_destroy(region_); | 50 gdk_region_destroy(region_); |
51 } | 51 } |
52 | 52 |
53 void CanvasSkiaPaint::Init(bool opaque) { | 53 void CanvasSkiaPaint::Init(bool opaque) { |
54 GdkRectangle bounds = rectangle(); | 54 GdkRectangle bounds = rectangle(); |
| 55 RecreateBackingCanvas(gfx::Size(bounds.width, bounds.height), |
| 56 ui::SCALE_FACTOR_100P, opaque); |
| 57 |
55 skia::PlatformCanvas* canvas = platform_canvas(); | 58 skia::PlatformCanvas* canvas = platform_canvas(); |
56 if (!canvas->initialize(bounds.width, bounds.height, opaque, NULL)) { | |
57 // Cause a deliberate crash; | |
58 CHECK(false); | |
59 } | |
60 // No need to clear the canvas, because cairo automatically performs the | |
61 // clear. | |
62 | 59 |
63 // Need to translate so that the dirty region appears at the origin of the | 60 // Need to translate so that the dirty region appears at the origin of the |
64 // surface. | 61 // surface. |
65 canvas->translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y)); | 62 canvas->translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y)); |
66 | 63 |
67 context_ = skia::BeginPlatformPaint(canvas); | 64 context_ = skia::BeginPlatformPaint(canvas); |
68 } | 65 } |
69 | 66 |
70 } // namespace gfx | 67 } // namespace gfx |
71 | 68 |
72 | 69 |
OLD | NEW |