OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "media/remoting/interstitial.h" | 5 #include "media/remoting/interstitial.h" |
6 | 6 |
7 #include <algorithm> // for std::max() | 7 #include <algorithm> // for std::max() |
8 | 8 |
9 #include "media/base/localized_strings.h" | 9 #include "media/base/localized_strings.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
11 #include "media/base/video_util.h" | 11 #include "media/base/video_util.h" |
12 #include "skia/ext/image_operations.h" | 12 #include "skia/ext/image_operations.h" |
13 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkTypeface.h" | 15 #include "third_party/skia/include/core/SkTypeface.h" |
16 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 16 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
17 #include "ui/gfx/color_palette.h" | 17 #include "ui/gfx/color_palette.h" |
18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
19 #include "ui/gfx/paint_vector_icon.h" | 19 #include "ui/gfx/paint_vector_icon.h" |
20 #include "ui/gfx/skbitmap_operations.h" | 20 #include "ui/gfx/skbitmap_operations.h" |
21 #include "ui/gfx/vector_icons_public.h" | 21 #include "ui/vector_icons/vector_icons.h" |
22 | 22 |
23 namespace media { | 23 namespace media { |
24 namespace remoting { | 24 namespace remoting { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // The interstitial frame size when |background_image| is empty or has low | 28 // The interstitial frame size when |background_image| is empty or has low |
29 // resolution. The frame height may be adjusted according to the aspect ratio of | 29 // resolution. The frame height may be adjusted according to the aspect ratio of |
30 // the |background_image|. | 30 // the |background_image|. |
31 constexpr int kDefaultFrameWidth = 1280; | 31 constexpr int kDefaultFrameWidth = 1280; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 SkScalar display_text_width = | 86 SkScalar display_text_width = |
87 paint.measureText(message.data(), message.size()); | 87 paint.measureText(message.data(), message.size()); |
88 SkScalar sk_text_offset_x = | 88 SkScalar sk_text_offset_x = |
89 SkScalarFloorToScalar((canvas_size.width() - display_text_width) / 2.0); | 89 SkScalarFloorToScalar((canvas_size.width() - display_text_width) / 2.0); |
90 SkScalar sk_text_offset_y = | 90 SkScalar sk_text_offset_y = |
91 SkScalarFloorToScalar((canvas_size.height() / 2.0) + text_height); | 91 SkScalarFloorToScalar((canvas_size.height() / 2.0) + text_height); |
92 canvas->drawText(message.data(), message.size(), sk_text_offset_x, | 92 canvas->drawText(message.data(), message.size(), sk_text_offset_x, |
93 sk_text_offset_y, paint); | 93 sk_text_offset_y, paint); |
94 | 94 |
95 // Draw the appropriate Cast icon. | 95 // Draw the appropriate Cast icon. |
96 gfx::VectorIconId current_icon = | 96 const gfx::VectorIcon& current_icon = type == InterstitialType::IN_SESSION |
97 (type == InterstitialType::IN_SESSION | 97 ? ui::kMediaRouterActiveIcon |
98 ? gfx::VectorIconId::MEDIA_ROUTER_ACTIVE | 98 : ui::kMediaRouterWarningIcon; |
99 : gfx::VectorIconId::MEDIA_ROUTER_WARNING); | |
100 gfx::ImageSkia icon_image = gfx::CreateVectorIcon( | 99 gfx::ImageSkia icon_image = gfx::CreateVectorIcon( |
101 current_icon, canvas_size.height() / 6, SK_ColorLTGRAY); | 100 current_icon, canvas_size.height() / 6, SK_ColorLTGRAY); |
102 const SkBitmap* icon_bitmap = icon_image.bitmap(); | 101 const SkBitmap* icon_bitmap = icon_image.bitmap(); |
103 SkScalar sk_image_offset_x = (canvas_size.width() - icon_image.width()) / 2.0; | 102 SkScalar sk_image_offset_x = (canvas_size.width() - icon_image.width()) / 2.0; |
104 SkScalar sk_image_offset_y = | 103 SkScalar sk_image_offset_y = |
105 (canvas_size.height() / 2.0) - icon_image.height(); | 104 (canvas_size.height() / 2.0) - icon_image.height(); |
106 canvas->drawBitmap(*icon_bitmap, sk_image_offset_x, sk_image_offset_y, | 105 canvas->drawBitmap(*icon_bitmap, sk_image_offset_x, sk_image_offset_y, |
107 &paint); | 106 &paint); |
108 } | 107 } |
109 | 108 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 CopyRGBToVideoFrame(reinterpret_cast<uint8_t*>(canvas_bitmap.getPixels()), | 156 CopyRGBToVideoFrame(reinterpret_cast<uint8_t*>(canvas_bitmap.getPixels()), |
158 canvas_bitmap.rowBytes(), | 157 canvas_bitmap.rowBytes(), |
159 gfx::Rect(canvas_size.width(), canvas_size.height()), | 158 gfx::Rect(canvas_size.width(), canvas_size.height()), |
160 video_frame.get()); | 159 video_frame.get()); |
161 } | 160 } |
162 return video_frame; | 161 return video_frame; |
163 } | 162 } |
164 | 163 |
165 } // namespace remoting | 164 } // namespace remoting |
166 } // namespace media | 165 } // namespace media |
OLD | NEW |