Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ui/gfx/canvas_paint_win.h

Issue 11138024: Simplify platform_canvas.h by recognizing that PlatformCanvas does not actually extend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/canvas_paint_gtk.cc ('k') | ui/gfx/image/image_skia_operations.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/canvas_paint.h" 10 #include "ui/gfx/canvas_paint.h"
11 #include "ui/gfx/size.h"
11 12
12 namespace gfx { 13 namespace gfx {
13 14
14 // A class designed to help with WM_PAINT operations on Windows. It will 15 // A class designed to help with WM_PAINT operations on Windows. It will
15 // do BeginPaint/EndPaint on init/destruction, and will create the bitmap and 16 // do BeginPaint/EndPaint on init/destruction, and will create the bitmap and
16 // canvas with the correct size and transform for the dirty rect. The bitmap 17 // canvas with the correct size and transform for the dirty rect. The bitmap
17 // will be automatically painted to the screen on destruction. 18 // will be automatically painted to the screen on destruction.
18 // 19 //
19 // You MUST call isEmpty before painting to determine if anything needs 20 // You MUST call isEmpty before painting to determine if anything needs
20 // painting. Sometimes the dirty rect can actually be empty, and this makes 21 // painting. Sometimes the dirty rect can actually be empty, and this makes
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 PAINTSTRUCT ps_; 96 PAINTSTRUCT ps_;
96 97
97 private: 98 private:
98 void initPaint(bool opaque) { 99 void initPaint(bool opaque) {
99 paint_dc_ = BeginPaint(hwnd_, &ps_); 100 paint_dc_ = BeginPaint(hwnd_, &ps_);
100 101
101 init(opaque); 102 init(opaque);
102 } 103 }
103 104
104 void init(bool opaque) { 105 void init(bool opaque) {
105 skia::PlatformCanvas* canvas = platform_canvas();
106 // FIXME(brettw) for ClearType, we probably want to expand the bounds of 106 // 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 107 // 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 108 // text can depend on the adjacent pixel). Then we would paint just the
109 // inset pixels to the screen. 109 // inset pixels to the screen.
110 const int width = ps_.rcPaint.right - ps_.rcPaint.left; 110 const int width = ps_.rcPaint.right - ps_.rcPaint.left;
111 const int height = ps_.rcPaint.bottom - ps_.rcPaint.top; 111 const int height = ps_.rcPaint.bottom - ps_.rcPaint.top;
112 if (!canvas->initialize(width, height, opaque, NULL)) { 112
113 // Cause a deliberate crash; 113 RecreateBackingCanvas(gfx::Size(width, height), ui::SCALE_FACTOR_100P,
114 __debugbreak(); 114 opaque);
115 _exit(1); 115 skia::PlatformCanvas* canvas = platform_canvas();
116 } 116
117 canvas->clear(SkColorSetARGB(0, 0, 0, 0)); 117 canvas->clear(SkColorSetARGB(0, 0, 0, 0));
118 118
119 // This will bring the canvas into the screen coordinate system for the 119 // This will bring the canvas into the screen coordinate system for the
120 // dirty rect 120 // dirty rect
121 canvas->translate(SkIntToScalar(-ps_.rcPaint.left), 121 canvas->translate(SkIntToScalar(-ps_.rcPaint.left),
122 SkIntToScalar(-ps_.rcPaint.top)); 122 SkIntToScalar(-ps_.rcPaint.top));
123 } 123 }
124 124
125 // If true, this canvas was created for a BeginPaint. 125 // If true, this canvas was created for a BeginPaint.
126 const bool for_paint_; 126 const bool for_paint_;
127 127
128 // Disallow copy and assign. 128 // Disallow copy and assign.
129 CanvasSkiaPaint(const CanvasSkiaPaint&); 129 CanvasSkiaPaint(const CanvasSkiaPaint&);
130 CanvasSkiaPaint& operator=(const CanvasSkiaPaint&); 130 CanvasSkiaPaint& operator=(const CanvasSkiaPaint&);
131 }; 131 };
132 132
133 } // namespace gfx 133 } // namespace gfx
134 134
135 #endif // UI_GFX_CANVAS_PAINT_WIN_H_ 135 #endif // UI_GFX_CANVAS_PAINT_WIN_H_
OLDNEW
« no previous file with comments | « ui/gfx/canvas_paint_gtk.cc ('k') | ui/gfx/image/image_skia_operations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698