| Index: chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc
|
| diff --git a/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc b/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc
|
| index 8b845449acd5912d5e82664b6857729a41af382c..6c80c63b4b591b11797a32610c6d517da7be15ae 100644
|
| --- a/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc
|
| +++ b/chrome/browser/android/vr_shell/textures/insecure_content_transient_texture.cc
|
| @@ -28,60 +28,63 @@ constexpr float kTextWidthFactor = 1.0 - 3 * kBorderFactor - kIconSizeFactor;
|
|
|
| } // namespace
|
|
|
| -InsecureContentTransientTexture::InsecureContentTransientTexture(
|
| - int texture_handle,
|
| - int texture_size)
|
| - : UITexture(texture_handle, texture_size) {
|
| -}
|
| +InsecureContentTransientTexture::InsecureContentTransientTexture() = default;
|
|
|
| InsecureContentTransientTexture::~InsecureContentTransientTexture() = default;
|
|
|
| -void InsecureContentTransientTexture::Draw(gfx::Canvas* canvas) {
|
| +void InsecureContentTransientTexture::Draw(gfx::Canvas* canvas,
|
| + const gfx::Size& texture_size) {
|
| + size_.set_width(texture_size.width());
|
| + int max_height = texture_size.height();
|
| cc::PaintFlags flags;
|
| flags.setColor(kBackgroundColor);
|
|
|
| int text_flags = gfx::Canvas::TEXT_ALIGN_CENTER | gfx::Canvas::MULTI_LINE;
|
| auto text =
|
| l10n_util::GetStringUTF16(IDS_PAGE_INFO_INSECURE_WEBVR_CONTENT_TRANSIENT);
|
| - auto fonts = GetFontList(texture_size_ * kFontSizeFactor, text);
|
| -
|
| - int text_width = texture_size_ * kTextWidthFactor;
|
| + auto fonts = GetFontList(size_.width() * kFontSizeFactor, text);
|
| + int text_width = size_.width() * kTextWidthFactor;
|
| int text_height = 0; // Will be increased during text measurement.
|
| gfx::Canvas::SizeStringInt(text, fonts, &text_width, &text_height, 0,
|
| text_flags);
|
| // Making sure that the icon fits in the box.
|
| text_height = std::max(
|
| - text_height, static_cast<int>(ceil(texture_size_ * kIconSizeFactor)));
|
| + text_height, static_cast<int>(ceil(size_.width() * kIconSizeFactor)));
|
| // Making sure the drawing fits within the texture.
|
| text_height = std::min(
|
| - text_height, static_cast<int>((1.0 - 2 * kBorderFactor) * texture_size_));
|
| - height_ =
|
| - static_cast<int>(ceil(texture_size_ * 2 * kBorderFactor + text_height));
|
| -
|
| - canvas->DrawRoundRect(gfx::Rect(texture_size_, height_),
|
| - height_ * kBorderFactor, flags);
|
| + text_height, static_cast<int>((1.0 - 2 * kBorderFactor) * size_.width()));
|
| + size_.set_height(size_.width() * 2 * kBorderFactor + text_height);
|
| + DCHECK_LE(size_.height(), max_height);
|
| + canvas->DrawRoundRect(gfx::Rect(size_.width(), size_.height()),
|
| + size_.height() * kBorderFactor, flags);
|
|
|
| canvas->Save();
|
| - canvas->Translate({IsRTL() ? 2 * kBorderFactor * texture_size_ + text_width
|
| - : texture_size_ * kBorderFactor,
|
| - (height_ - kIconSizeFactor * texture_size_) / 2.0});
|
| - PaintVectorIcon(canvas, ui::kInfoOutlineIcon, texture_size_ * kIconSizeFactor,
|
| + canvas->Translate(
|
| + gfx::Vector2d(IsRTL() ? 2 * kBorderFactor * size_.width() + text_width
|
| + : size_.width() * kBorderFactor,
|
| + (size_.height() - kIconSizeFactor * size_.width()) / 2.0));
|
| + PaintVectorIcon(canvas, ui::kInfoOutlineIcon, size_.width() * kIconSizeFactor,
|
| kForegroundColor);
|
| canvas->Restore();
|
|
|
| canvas->Save();
|
| - canvas->Translate(
|
| - {IsRTL() ? kBorderFactor * texture_size_
|
| - : texture_size_ * (2 * kBorderFactor + kIconSizeFactor),
|
| - texture_size_ * kBorderFactor});
|
| + canvas->Translate(gfx::Vector2d(
|
| + IsRTL() ? kBorderFactor * size_.width()
|
| + : size_.width() * (2 * kBorderFactor + kIconSizeFactor),
|
| + size_.width() * kBorderFactor));
|
| canvas->DrawStringRectWithFlags(
|
| text, fonts, kForegroundColor,
|
| - gfx::Rect(kTextWidthFactor * texture_size_, text_height), text_flags);
|
| + gfx::Rect(kTextWidthFactor * size_.width(), text_height), text_flags);
|
| canvas->Restore();
|
| }
|
|
|
| -void InsecureContentTransientTexture::SetSize() {
|
| - size_.SetSize(texture_size_, height_);
|
| +gfx::Size InsecureContentTransientTexture::GetPreferredTextureSize(
|
| + int maximum_width) const {
|
| + return gfx::Size(maximum_width, maximum_width);
|
| +}
|
| +
|
| +gfx::SizeF InsecureContentTransientTexture::GetDrawnSize() const {
|
| + return size_;
|
| }
|
|
|
| } // namespace vr_shell
|
|
|