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

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"
11 #include "core/editing/markers/TextMatchMarker.h" 11 #include "core/editing/markers/TextMatchMarker.h"
12 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
13 #include "core/layout/LayoutTextCombine.h" 13 #include "core/layout/LayoutTextCombine.h"
14 #include "core/layout/LayoutTheme.h" 14 #include "core/layout/LayoutTheme.h"
15 #include "core/layout/api/LineLayoutAPIShim.h" 15 #include "core/layout/api/LineLayoutAPIShim.h"
16 #include "core/layout/api/LineLayoutBox.h" 16 #include "core/layout/api/LineLayoutBox.h"
17 #include "core/layout/line/InlineTextBox.h" 17 #include "core/layout/line/InlineTextBox.h"
18 #include "core/paint/AppliedDecorationPainter.h" 18 #include "core/paint/AppliedDecorationPainter.h"
19 #include "core/paint/DecorationInfo.h" 19 #include "core/paint/DecorationInfo.h"
20 #include "core/paint/PaintInfo.h" 20 #include "core/paint/PaintInfo.h"
21 #include "core/paint/TextPainter.h" 21 #include "core/paint/TextPainter.h"
22 #include "platform/graphics/GraphicsContextStateSaver.h" 22 #include "platform/graphics/GraphicsContextStateSaver.h"
23 #include "platform/graphics/paint/DrawingRecorder.h" 23 #include "platform/graphics/paint/DrawingRecorder.h"
24 #include "platform/graphics/paint/PaintRecord.h" 24 #include "platform/graphics/paint/PaintRecord.h"
25 #include "platform/graphics/paint/PaintRecorder.h" 25 #include "platform/graphics/paint/PaintRecorder.h"
26 #include "platform/graphics/paint/PaintShader.h"
26 #include "platform/wtf/Optional.h" 27 #include "platform/wtf/Optional.h"
27 #include "third_party/skia/include/effects/SkGradientShader.h" 28 #include "third_party/skia/include/effects/SkGradientShader.h"
28 29
29 namespace blink { 30 namespace blink {
30 31
31 namespace { 32 namespace {
32 33
33 std::pair<unsigned, unsigned> GetMarkerPaintOffsets( 34 std::pair<unsigned, unsigned> GetMarkerPaintOffsets(
34 const DocumentMarker& marker, 35 const DocumentMarker& marker,
35 const InlineTextBox& text_box) { 36 const InlineTextBox& text_box) {
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 color 762 color
762 }; 763 };
763 const SkPoint pts[2] = { 764 const SkPoint pts[2] = {
764 SkPoint::Make(0, 0), 765 SkPoint::Make(0, 0),
765 SkPoint::Make(0, 2 * kR) 766 SkPoint::Make(0, 2 * kR)
766 }; 767 };
767 768
768 PaintFlags flags; 769 PaintFlags flags;
769 flags.setAntiAlias(true); 770 flags.setAntiAlias(true);
770 flags.setColor(color); 771 flags.setColor(color);
771 flags.setShader(SkGradientShader::MakeLinear( 772 flags.setShader(PaintShader::MakeLinearGradient(
772 pts, colors, nullptr, ARRAY_SIZE(colors), SkShader::kClamp_TileMode)); 773 pts, colors, nullptr, ARRAY_SIZE(colors), SkShader::kClamp_TileMode));
773 PaintRecorder recorder; 774 PaintRecorder recorder;
774 recorder.beginRecording(kMarkerWidth, kMarkerHeight); 775 recorder.beginRecording(kMarkerWidth, kMarkerHeight);
775 recorder.getRecordingCanvas()->drawCircle(kR, kR, kR, flags); 776 recorder.getRecordingCanvas()->drawCircle(kR, kR, kR, flags);
776 777
777 return recorder.finishRecordingAsPicture(); 778 return recorder.finishRecordingAsPicture();
778 } 779 }
779 780
780 #endif // OS(MACOSX) 781 #endif // OS(MACOSX)
781 782
(...skipping 23 matching lines...) Expand all
805 #else 806 #else
806 // 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.
807 origin_y += 1; 808 origin_y += 1;
808 #endif 809 #endif
809 810
810 const auto rect = SkRect::MakeWH(width, kMarkerHeight * zoom); 811 const auto rect = SkRect::MakeWH(width, kMarkerHeight * zoom);
811 const auto local_matrix = SkMatrix::MakeScale(zoom, zoom); 812 const auto local_matrix = SkMatrix::MakeScale(zoom, zoom);
812 813
813 PaintFlags flags; 814 PaintFlags flags;
814 flags.setAntiAlias(true); 815 flags.setAntiAlias(true);
815 flags.setShader(WrapSkShader(MakePaintShaderRecord( 816 flags.setShader(PaintShader::MakePaintRecord(
816 sk_ref_sp(marker), FloatRect(0, 0, kMarkerWidth, kMarkerHeight), 817 sk_ref_sp(marker), FloatRect(0, 0, kMarkerWidth, kMarkerHeight),
817 SkShader::kRepeat_TileMode, SkShader::kClamp_TileMode, &local_matrix))); 818 SkShader::kRepeat_TileMode, SkShader::kClamp_TileMode, &local_matrix));
818 819
819 // 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
820 // 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
821 // cached tile for all markers at a given zoom level. 822 // cached tile for all markers at a given zoom level.
822 GraphicsContextStateSaver saver(context); 823 GraphicsContextStateSaver saver(context);
823 context.Translate(origin_x, origin_y); 824 context.Translate(origin_x, origin_y);
824 context.DrawRect(rect, flags); 825 context.DrawRect(rect, flags);
825 } 826 }
826 827
827 } // anonymous ns 828 } // anonymous ns
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 1176
1176 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(), 1177 LayoutRect box_rect(box_origin, LayoutSize(inline_text_box_.LogicalWidth(),
1177 inline_text_box_.LogicalHeight())); 1178 inline_text_box_.LogicalHeight()));
1178 context.Clip(FloatRect(box_rect)); 1179 context.Clip(FloatRect(box_rect));
1179 context.DrawHighlightForText(font, run, FloatPoint(box_origin), 1180 context.DrawHighlightForText(font, run, FloatPoint(box_origin),
1180 box_rect.Height().ToInt(), color, 1181 box_rect.Height().ToInt(), color,
1181 paint_offsets.first, paint_offsets.second); 1182 paint_offsets.first, paint_offsets.second);
1182 } 1183 }
1183 1184
1184 } // namespace blink 1185 } // namespace blink
OLDNEW
« no previous file with comments | « content/browser/web_contents/aura/shadow_layer_delegate.cc ('k') | third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698