| 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 #ifndef UI_GFX_CANVAS_H_ | 5 #ifndef UI_GFX_CANVAS_H_ |
| 6 #define UI_GFX_CANVAS_H_ | 6 #define UI_GFX_CANVAS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 NO_ELLIPSIS = 1 << 7, | 68 NO_ELLIPSIS = 1 << 7, |
| 69 | 69 |
| 70 // Specifies if words can be split by new lines. | 70 // Specifies if words can be split by new lines. |
| 71 // This only works with MULTI_LINE. | 71 // This only works with MULTI_LINE. |
| 72 CHARACTER_BREAK = 1 << 8, | 72 CHARACTER_BREAK = 1 << 8, |
| 73 | 73 |
| 74 // Instructs DrawStringRect() to not use subpixel rendering. This is useful | 74 // Instructs DrawStringRect() to not use subpixel rendering. This is useful |
| 75 // when rendering text onto a fully- or partially-transparent background | 75 // when rendering text onto a fully- or partially-transparent background |
| 76 // that will later be blended with another image. | 76 // that will later be blended with another image. |
| 77 NO_SUBPIXEL_RENDERING = 1 << 9, | 77 NO_SUBPIXEL_RENDERING = 1 << 9, |
| 78 | |
| 79 // Draw text with 1px border. | |
| 80 HALO_EFFECT = 1 << 10, | |
| 81 }; | 78 }; |
| 82 | 79 |
| 83 // Creates an empty canvas with image_scale of 1x. | 80 // Creates an empty canvas with image_scale of 1x. |
| 84 Canvas(); | 81 Canvas(); |
| 85 | 82 |
| 86 // Creates canvas with provided DIP |size| and |image_scale|. | 83 // Creates canvas with provided DIP |size| and |image_scale|. |
| 87 // If this canvas is not opaque, it's explicitly cleared to transparent before | 84 // If this canvas is not opaque, it's explicitly cleared to transparent before |
| 88 // being returned. | 85 // being returned. |
| 89 Canvas(const Size& size, float image_scale, bool is_opaque); | 86 Canvas(const Size& size, float image_scale, bool is_opaque); |
| 90 | 87 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 140 |
| 144 // Returns the default text alignment to be used when drawing text on a | 141 // Returns the default text alignment to be used when drawing text on a |
| 145 // Canvas based on the directionality of the system locale language. | 142 // Canvas based on the directionality of the system locale language. |
| 146 // This function is used by Canvas::DrawStringRect when the text alignment | 143 // This function is used by Canvas::DrawStringRect when the text alignment |
| 147 // is not specified. | 144 // is not specified. |
| 148 // | 145 // |
| 149 // This function returns either Canvas::TEXT_ALIGN_LEFT or | 146 // This function returns either Canvas::TEXT_ALIGN_LEFT or |
| 150 // Canvas::TEXT_ALIGN_RIGHT. | 147 // Canvas::TEXT_ALIGN_RIGHT. |
| 151 static int DefaultCanvasTextAlignment(); | 148 static int DefaultCanvasTextAlignment(); |
| 152 | 149 |
| 153 // Draws text with a 1-pixel halo around it of the given color. | |
| 154 // On Windows, it allows ClearType to be drawn to an otherwise transparent | |
| 155 // bitmap for drag images. Drag images have only 1-bit of transparency, so | |
| 156 // we don't do any fancy blurring. | |
| 157 // On Linux, text with halo is created by stroking it with 2px |halo_color| | |
| 158 // then filling it with |text_color|. | |
| 159 // On Mac, NOTIMPLEMENTED. | |
| 160 // TODO(dhollowa): Skia-native implementation is underway. Cut over to | |
| 161 // that when ready. http::/crbug.com/109946 | |
| 162 void DrawStringRectWithHalo(const base::string16& text, | |
| 163 const FontList& font_list, | |
| 164 SkColor text_color, | |
| 165 SkColor halo_color, | |
| 166 const Rect& display_rect, | |
| 167 int flags); | |
| 168 | |
| 169 // Extracts an ImageSkiaRep from the contents of this canvas. | 150 // Extracts an ImageSkiaRep from the contents of this canvas. |
| 170 ImageSkiaRep ExtractImageRep() const; | 151 ImageSkiaRep ExtractImageRep() const; |
| 171 | 152 |
| 172 // Draws a dashed rectangle of the specified color. | 153 // Draws a dashed rectangle of the specified color. |
| 173 // DEPRECATED in favor of the RectF version below. | 154 // DEPRECATED in favor of the RectF version below. |
| 174 // TODO(funkysidd): Remove this (http://crbug.com/553726) | 155 // TODO(funkysidd): Remove this (http://crbug.com/553726) |
| 175 void DrawDashedRect(const Rect& rect, SkColor color); | 156 void DrawDashedRect(const Rect& rect, SkColor color); |
| 176 | 157 |
| 177 // Draws a dashed rectangle of the specified color. | 158 // Draws a dashed rectangle of the specified color. |
| 178 void DrawDashedRect(const RectF& rect, SkColor color); | 159 void DrawDashedRect(const RectF& rect, SkColor color); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 base::Optional<SkBitmap> bitmap_; | 497 base::Optional<SkBitmap> bitmap_; |
| 517 base::Optional<cc::SkiaPaintCanvas> owned_canvas_; | 498 base::Optional<cc::SkiaPaintCanvas> owned_canvas_; |
| 518 cc::PaintCanvas* canvas_; | 499 cc::PaintCanvas* canvas_; |
| 519 | 500 |
| 520 DISALLOW_COPY_AND_ASSIGN(Canvas); | 501 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 521 }; | 502 }; |
| 522 | 503 |
| 523 } // namespace gfx | 504 } // namespace gfx |
| 524 | 505 |
| 525 #endif // UI_GFX_CANVAS_H_ | 506 #endif // UI_GFX_CANVAS_H_ |
| OLD | NEW |