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

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

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build 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
OLDNEW
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_RENDER_TEXT_H_ 5 #ifndef UI_GFX_RENDER_TEXT_H_
6 #define UI_GFX_RENDER_TEXT_H_ 6 #define UI_GFX_RENDER_TEXT_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/string16.h" 16 #include "base/string16.h"
17 #include "third_party/skia/include/core/SkColor.h" 17 #include "third_party/skia/include/core/SkColor.h"
18 #include "third_party/skia/include/core/SkPaint.h" 18 #include "third_party/skia/include/core/SkPaint.h"
19 #include "third_party/skia/include/core/SkRect.h" 19 #include "third_party/skia/include/core/SkRect.h"
20 #include "ui/base/range/range.h" 20 #include "ui/base/range/range.h"
21 #include "ui/gfx/font_list.h" 21 #include "ui/gfx/font_list.h"
22 #include "ui/gfx/point.h" 22 #include "ui/gfx/point.h"
23 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
24 #include "ui/gfx/selection_model.h" 24 #include "ui/gfx/selection_model.h"
25 #include "ui/gfx/shadow_value.h" 25 #include "ui/gfx/shadow_value.h"
26 #include "ui/gfx/text_constants.h" 26 #include "ui/gfx/text_constants.h"
27 #include "ui/gfx/vector2d.h"
27 28
28 class SkCanvas; 29 class SkCanvas;
29 class SkDrawLooper; 30 class SkDrawLooper;
30 struct SkPoint; 31 struct SkPoint;
31 class SkShader; 32 class SkShader;
32 class SkTypeface; 33 class SkTypeface;
33 34
34 namespace gfx { 35 namespace gfx {
35 36
36 class Canvas; 37 class Canvas;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 typedef std::pair<Font, ui::Range> FontSpan; 288 typedef std::pair<Font, ui::Range> FontSpan;
288 // For testing purposes, returns which fonts were chosen for which parts of 289 // For testing purposes, returns which fonts were chosen for which parts of
289 // the text by returning a vector of Font and Range pairs, where each range 290 // the text by returning a vector of Font and Range pairs, where each range
290 // specifies the character range for which the corresponding font has been 291 // specifies the character range for which the corresponding font has been
291 // chosen. 292 // chosen.
292 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0; 293 virtual std::vector<FontSpan> GetFontSpansForTesting() = 0;
293 294
294 protected: 295 protected:
295 RenderText(); 296 RenderText();
296 297
297 const Point& GetUpdatedDisplayOffset(); 298 const Vector2d& GetUpdatedDisplayOffset();
298 299
299 void set_cached_bounds_and_offset_valid(bool valid) { 300 void set_cached_bounds_and_offset_valid(bool valid) {
300 cached_bounds_and_offset_valid_ = valid; 301 cached_bounds_and_offset_valid_ = valid;
301 } 302 }
302 303
303 const StyleRanges& style_ranges() const { return style_ranges_; } 304 const StyleRanges& style_ranges() const { return style_ranges_; }
304 305
305 // Get the selection model that visually neighbors |position| by |break_type|. 306 // Get the selection model that visually neighbors |position| by |break_type|.
306 // The returned value represents a cursor/caret position without a selection. 307 // The returned value represents a cursor/caret position without a selection.
307 SelectionModel GetAdjacentSelectionModel(const SelectionModel& current, 308 SelectionModel GetAdjacentSelectionModel(const SelectionModel& current,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 // Convert points from the text space to the view space and back. 374 // Convert points from the text space to the view space and back.
374 // Handles the display area, display offset, and the application LTR/RTL mode. 375 // Handles the display area, display offset, and the application LTR/RTL mode.
375 Point ToTextPoint(const Point& point); 376 Point ToTextPoint(const Point& point);
376 Point ToViewPoint(const Point& point); 377 Point ToViewPoint(const Point& point);
377 378
378 // Returns the width of content, which reserves room for the cursor if 379 // Returns the width of content, which reserves room for the cursor if
379 // |cursor_enabled_| is true. 380 // |cursor_enabled_| is true.
380 int GetContentWidth(); 381 int GetContentWidth();
381 382
382 // Returns display offset based on current text alignment. 383 // Returns display offset based on current text alignment.
383 Point GetAlignmentOffset(); 384 Vector2d GetAlignmentOffset();
384 385
385 // Returns the origin point for drawing text. Does not account for font 386 // Returns the origin point for drawing text. Does not account for font
386 // baseline, as needed by Skia. 387 // baseline, as needed by Skia.
387 Point GetOriginForDrawing(); 388 Point GetOriginForDrawing();
388 389
389 // Applies fade effects to |renderer|. 390 // Applies fade effects to |renderer|.
390 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer); 391 void ApplyFadeEffects(internal::SkiaTextRenderer* renderer);
391 392
392 // Applies text shadows to |renderer|. 393 // Applies text shadows to |renderer|.
393 void ApplyTextShadows(internal::SkiaTextRenderer* renderer); 394 void ApplyTextShadows(internal::SkiaTextRenderer* renderer);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 Rect display_rect_; 498 Rect display_rect_;
498 499
499 // Flag to work around a Skia bug with the PDF path (http://crbug.com/133548) 500 // Flag to work around a Skia bug with the PDF path (http://crbug.com/133548)
500 // that results in incorrect clipping when drawing to the document margins. 501 // that results in incorrect clipping when drawing to the document margins.
501 // This field allows disabling clipping to work around the issue. 502 // This field allows disabling clipping to work around the issue.
502 // TODO(asvitkine): Remove this when the underlying Skia bug is fixed. 503 // TODO(asvitkine): Remove this when the underlying Skia bug is fixed.
503 bool clip_to_display_rect_; 504 bool clip_to_display_rect_;
504 505
505 // The offset for the text to be drawn, relative to the display area. 506 // The offset for the text to be drawn, relative to the display area.
506 // Get this point with GetUpdatedDisplayOffset (or risk using a stale value). 507 // Get this point with GetUpdatedDisplayOffset (or risk using a stale value).
507 Point display_offset_; 508 Vector2d display_offset_;
508 509
509 // The cached bounds and offset are invalidated by changes to the cursor, 510 // The cached bounds and offset are invalidated by changes to the cursor,
510 // selection, font, and other operations that adjust the visible text bounds. 511 // selection, font, and other operations that adjust the visible text bounds.
511 bool cached_bounds_and_offset_valid_; 512 bool cached_bounds_and_offset_valid_;
512 513
513 // Text shadows to be drawn. 514 // Text shadows to be drawn.
514 ShadowValues text_shadows_; 515 ShadowValues text_shadows_;
515 516
516 DISALLOW_COPY_AND_ASSIGN(RenderText); 517 DISALLOW_COPY_AND_ASSIGN(RenderText);
517 }; 518 };
518 519
519 } // namespace gfx 520 } // namespace gfx
520 521
521 #endif // UI_GFX_RENDER_TEXT_H_ 522 #endif // UI_GFX_RENDER_TEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698