| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef UI_GFX_CANVAS_PAINT_WIN_H_ | 5 #ifndef UI_GFX_CANVAS_PAINT_WIN_H_ |
| 6 #define UI_GFX_CANVAS_PAINT_WIN_H_ | 6 #define UI_GFX_CANVAS_PAINT_WIN_H_ |
| 7 | 7 |
| 8 #include "skia/ext/platform_canvas.h" | 8 #include "skia/ext/platform_canvas.h" |
| 9 #include "ui/base/win/dpi.h" |
| 9 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/canvas_paint.h" | 11 #include "ui/gfx/canvas_paint.h" |
| 11 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
| 12 | 13 |
| 13 namespace gfx { | 14 namespace gfx { |
| 14 | 15 |
| 15 // A class designed to help with WM_PAINT operations on Windows. It will | 16 // A class designed to help with WM_PAINT operations on Windows. It will |
| 16 // do BeginPaint/EndPaint on init/destruction, and will create the bitmap and | 17 // do BeginPaint/EndPaint on init/destruction, and will create the bitmap and |
| 17 // canvas with the correct size and transform for the dirty rect. The bitmap | 18 // canvas with the correct size and transform for the dirty rect. The bitmap |
| 18 // will be automatically painted to the screen on destruction. | 19 // will be automatically painted to the screen on destruction. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 104 } |
| 104 | 105 |
| 105 void init(bool opaque) { | 106 void init(bool opaque) { |
| 106 // FIXME(brettw) for ClearType, we probably want to expand the bounds of | 107 // FIXME(brettw) for ClearType, we probably want to expand the bounds of |
| 107 // painting by one pixel so that the boundaries will be correct (ClearType | 108 // painting by one pixel so that the boundaries will be correct (ClearType |
| 108 // text can depend on the adjacent pixel). Then we would paint just the | 109 // text can depend on the adjacent pixel). Then we would paint just the |
| 109 // inset pixels to the screen. | 110 // inset pixels to the screen. |
| 110 const int width = ps_.rcPaint.right - ps_.rcPaint.left; | 111 const int width = ps_.rcPaint.right - ps_.rcPaint.left; |
| 111 const int height = ps_.rcPaint.bottom - ps_.rcPaint.top; | 112 const int height = ps_.rcPaint.bottom - ps_.rcPaint.top; |
| 112 | 113 |
| 113 RecreateBackingCanvas(gfx::Size(width, height), ui::SCALE_FACTOR_100P, | 114 RecreateBackingCanvas(gfx::Size(width, height), |
| 114 opaque); | 115 ui::GetScaleFactorFromScale(ui::win::GetDeviceScaleFactor()), |
| 116 opaque); |
| 115 skia::PlatformCanvas* canvas = platform_canvas(); | 117 skia::PlatformCanvas* canvas = platform_canvas(); |
| 116 | 118 |
| 117 canvas->clear(SkColorSetARGB(0, 0, 0, 0)); | 119 canvas->clear(SkColorSetARGB(0, 0, 0, 0)); |
| 118 | 120 |
| 119 // This will bring the canvas into the screen coordinate system for the | 121 // This will bring the canvas into the screen coordinate system for the |
| 120 // dirty rect | 122 // dirty rect |
| 121 canvas->translate(SkIntToScalar(-ps_.rcPaint.left), | 123 canvas->translate( |
| 122 SkIntToScalar(-ps_.rcPaint.top)); | 124 SkScalarRoundToInt(-ps_.rcPaint.left/ui::win::GetDeviceScaleFactor()), |
| 125 SkScalarRoundToInt(-ps_.rcPaint.top/ui::win::GetDeviceScaleFactor())); |
| 123 } | 126 } |
| 124 | 127 |
| 125 // If true, this canvas was created for a BeginPaint. | 128 // If true, this canvas was created for a BeginPaint. |
| 126 const bool for_paint_; | 129 const bool for_paint_; |
| 127 | 130 |
| 128 // Disallow copy and assign. | 131 // Disallow copy and assign. |
| 129 CanvasSkiaPaint(const CanvasSkiaPaint&); | 132 CanvasSkiaPaint(const CanvasSkiaPaint&); |
| 130 CanvasSkiaPaint& operator=(const CanvasSkiaPaint&); | 133 CanvasSkiaPaint& operator=(const CanvasSkiaPaint&); |
| 131 }; | 134 }; |
| 132 | 135 |
| 133 } // namespace gfx | 136 } // namespace gfx |
| 134 | 137 |
| 135 #endif // UI_GFX_CANVAS_PAINT_WIN_H_ | 138 #endif // UI_GFX_CANVAS_PAINT_WIN_H_ |
| OLD | NEW |