| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/common/gfx/chrome_canvas.h" | 5 #include "chrome/common/gfx/chrome_canvas.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 ReleaseDC(NULL, dc); | 152 ReleaseDC(NULL, dc); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void ChromeCanvas::DrawStringInt(const std::wstring& text, HFONT font, | 155 void ChromeCanvas::DrawStringInt(const std::wstring& text, HFONT font, |
| 156 const SkColor& color, int x, int y, int w, | 156 const SkColor& color, int x, int y, int w, |
| 157 int h, int flags) { | 157 int h, int flags) { |
| 158 if (!IntersectsClipRectInt(x, y, w, h)) | 158 if (!IntersectsClipRectInt(x, y, w, h)) |
| 159 return; | 159 return; |
| 160 | 160 |
| 161 getTopPlatformDevice().prepareForGDI(x, y, w, h); | |
| 162 RECT text_bounds = { x, y, x + w, y + h }; | 161 RECT text_bounds = { x, y, x + w, y + h }; |
| 163 HDC dc = beginPlatformPaint(); | 162 HDC dc = beginPlatformPaint(); |
| 164 SetBkMode(dc, TRANSPARENT); | 163 SetBkMode(dc, TRANSPARENT); |
| 165 HFONT old_font = (HFONT)SelectObject(dc, font); | 164 HFONT old_font = (HFONT)SelectObject(dc, font); |
| 166 COLORREF brush_color = RGB(SkColorGetR(color), SkColorGetG(color), | 165 COLORREF brush_color = RGB(SkColorGetR(color), SkColorGetG(color), |
| 167 SkColorGetB(color)); | 166 SkColorGetB(color)); |
| 168 SetTextColor(dc, brush_color); | 167 SetTextColor(dc, brush_color); |
| 169 | 168 |
| 170 int f = ComputeFormatFlags(flags, text); | 169 int f = ComputeFormatFlags(flags, text); |
| 171 DoDrawText(dc, text, &text_bounds, f); | 170 DoDrawText(dc, text, &text_bounds, f); |
| 172 endPlatformPaint(); | 171 endPlatformPaint(); |
| 173 | 172 |
| 174 // Restore the old font. This way we don't have to worry if the caller | 173 // Restore the old font. This way we don't have to worry if the caller |
| 175 // deletes the font and the DC lives longer. | 174 // deletes the font and the DC lives longer. |
| 176 SelectObject(dc, old_font); | 175 SelectObject(dc, old_font); |
| 177 getTopPlatformDevice().postProcessGDI(x, y, w, h); | 176 |
| 177 // Windows will have cleared the alpha channel of the text we drew. Assume |
| 178 // we're drawing to an opaque surface, or at least the text rect area is |
| 179 // opaque. |
| 180 getTopPlatformDevice().makeOpaque(x, y, w, h); |
| 178 } | 181 } |
| 179 | 182 |
| 180 void ChromeCanvas::DrawStringInt(const std::wstring& text, | 183 void ChromeCanvas::DrawStringInt(const std::wstring& text, |
| 181 const ChromeFont& font, | 184 const ChromeFont& font, |
| 182 const SkColor& color, | 185 const SkColor& color, |
| 183 int x, int y, | 186 int x, int y, |
| 184 int w, int h) { | 187 int w, int h) { |
| 185 DrawStringInt(text, font, color, x, y, w, h, | 188 DrawStringInt(text, font, color, x, y, w, h, |
| 186 l10n_util::DefaultCanvasTextAlignment()); | 189 l10n_util::DefaultCanvasTextAlignment()); |
| 187 } | 190 } |
| 188 | 191 |
| 189 void ChromeCanvas::DrawStringInt(const std::wstring& text, | 192 void ChromeCanvas::DrawStringInt(const std::wstring& text, |
| 190 const ChromeFont& font, | 193 const ChromeFont& font, |
| 191 const SkColor& color, | 194 const SkColor& color, |
| 192 int x, int y, int w, int h, int flags) { | 195 int x, int y, int w, int h, int flags) { |
| 193 DrawStringInt(text, font.hfont(), color, x, y, w, h, flags); | 196 DrawStringInt(text, font.hfont(), color, x, y, w, h, flags); |
| 194 } | 197 } |
| OLD | NEW |