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

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

Issue 11418217: Add skia::RefPtr class to wrap ref counted classes from Skia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop TNoRef Created 8 years 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 #include "ui/gfx/render_text.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/break_iterator.h" 9 #include "base/i18n/break_iterator.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 const SkColor color = default_style().foreground; 918 const SkColor color = default_style().foreground;
919 SkShader* shader = CreateFadeShader(text_rect, left_part, right_part, color); 919 SkShader* shader = CreateFadeShader(text_rect, left_part, right_part, color);
920 SkAutoUnref auto_unref(shader); 920 SkAutoUnref auto_unref(shader);
921 if (shader) { 921 if (shader) {
922 // |renderer| adds its own ref. So don't |release()| it from the ref ptr. 922 // |renderer| adds its own ref. So don't |release()| it from the ref ptr.
923 renderer->SetShader(shader, display_rect()); 923 renderer->SetShader(shader, display_rect());
924 } 924 }
925 } 925 }
926 926
927 void RenderText::ApplyTextShadows(internal::SkiaTextRenderer* renderer) { 927 void RenderText::ApplyTextShadows(internal::SkiaTextRenderer* renderer) {
928 SkDrawLooper* looper = gfx::CreateShadowDrawLooper(text_shadows_); 928 skia::RefPtr<SkDrawLooper> looper =
929 SkAutoUnref auto_unref(looper); 929 gfx::CreateShadowDrawLooper(text_shadows_);
930 renderer->SetDrawLooper(looper); 930 renderer->SetDrawLooper(looper.get());
931 } 931 }
932 932
933 // static 933 // static
934 bool RenderText::RangeContainsCaret(const ui::Range& range, 934 bool RenderText::RangeContainsCaret(const ui::Range& range,
935 size_t caret_pos, 935 size_t caret_pos,
936 LogicalCursorDirection caret_affinity) { 936 LogicalCursorDirection caret_affinity) {
937 // NB: exploits unsigned wraparound (WG14/N1124 section 6.2.5 paragraph 9). 937 // NB: exploits unsigned wraparound (WG14/N1124 section 6.2.5 paragraph 9).
938 size_t adjacent = (caret_affinity == CURSOR_BACKWARD) ? 938 size_t adjacent = (caret_affinity == CURSOR_BACKWARD) ?
939 caret_pos - 1 : caret_pos + 1; 939 caret_pos - 1 : caret_pos + 1;
940 return range.Contains(ui::Range(caret_pos, adjacent)); 940 return range.Contains(ui::Range(caret_pos, adjacent));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 if (cursor_enabled() && cursor_visible() && focused()) { 1019 if (cursor_enabled() && cursor_visible() && focused()) {
1020 const Rect& bounds = GetUpdatedCursorBounds(); 1020 const Rect& bounds = GetUpdatedCursorBounds();
1021 if (bounds.width() != 0) 1021 if (bounds.width() != 0)
1022 canvas->FillRect(bounds, cursor_color_); 1022 canvas->FillRect(bounds, cursor_color_);
1023 else 1023 else
1024 canvas->DrawRect(bounds, cursor_color_); 1024 canvas->DrawRect(bounds, cursor_color_);
1025 } 1025 }
1026 } 1026 }
1027 1027
1028 } // namespace gfx 1028 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698