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: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 2893083002: cc: Move SkShader construction to a single spot in PaintShader (Closed)
Patch Set: update Created 3 years, 6 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/paint/InlineTextBoxPainter.h" 5 #include "core/paint/InlineTextBoxPainter.h"
6 6
7 #include "core/editing/CompositionUnderline.h" 7 #include "core/editing/CompositionUnderline.h"
8 #include "core/editing/Editor.h" 8 #include "core/editing/Editor.h"
9 #include "core/editing/markers/CompositionMarker.h" 9 #include "core/editing/markers/CompositionMarker.h"
10 #include "core/editing/markers/DocumentMarkerController.h" 10 #include "core/editing/markers/DocumentMarkerController.h"
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 #else 806 #else
807 // Offset it vertically by 1 so that there's some space under the text. 807 // Offset it vertically by 1 so that there's some space under the text.
808 origin_y += 1; 808 origin_y += 1;
809 #endif 809 #endif
810 810
811 const auto rect = SkRect::MakeWH(width, kMarkerHeight * zoom); 811 const auto rect = SkRect::MakeWH(width, kMarkerHeight * zoom);
812 const auto local_matrix = SkMatrix::MakeScale(zoom, zoom); 812 const auto local_matrix = SkMatrix::MakeScale(zoom, zoom);
813 813
814 PaintFlags flags; 814 PaintFlags flags;
815 flags.setAntiAlias(true); 815 flags.setAntiAlias(true);
816 flags.setShader(WrapSkShader(MakePaintShaderRecord( 816 flags.setShader(WTF::MakeUnique<PaintShader>(
817 sk_ref_sp(marker), FloatRect(0, 0, kMarkerWidth, kMarkerHeight), 817 sk_ref_sp(marker), FloatRect(0, 0, kMarkerWidth, kMarkerHeight),
818 SkShader::kRepeat_TileMode, SkShader::kClamp_TileMode, &local_matrix))); 818 SkShader::kRepeat_TileMode, SkShader::kClamp_TileMode, &local_matrix));
819 819
820 // Apply the origin translation as a global transform. This ensures that the 820 // Apply the origin translation as a global transform. This ensures that the
821 // shader local matrix depends solely on zoom => Skia can reuse the same 821 // shader local matrix depends solely on zoom => Skia can reuse the same
822 // cached tile for all markers at a given zoom level. 822 // cached tile for all markers at a given zoom level.
823 GraphicsContextStateSaver saver(context); 823 GraphicsContextStateSaver saver(context);
824 context.Translate(origin_x, origin_y); 824 context.Translate(origin_x, origin_y);
825 context.DrawRect(rect, flags); 825 context.DrawRect(rect, flags);
826 } 826 }
827 827
828 } // anonymous ns 828 } // anonymous ns
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1176
1177 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), 1177 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(),
1178 inline_text_box_.LogicalHeight())); 1178 inline_text_box_.LogicalHeight()));
1179 context.Clip(FloatRect(box_rect)); 1179 context.Clip(FloatRect(box_rect));
1180 context.DrawHighlightForText(font, run, FloatPoint(box_origin), 1180 context.DrawHighlightForText(font, run, FloatPoint(box_origin),
1181 box_rect.Height().ToInt(), color, 1181 box_rect.Height().ToInt(), color,
1182 paint_offsets.first, paint_offsets.second); 1182 paint_offsets.first, paint_offsets.second);
1183 } 1183 }
1184 1184
1185 } // namespace blink 1185 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698