Commit 62f57782 authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for blink::BitmapImage

This CL has two goals,
  1. Use To<BitmapImage> and DynamicTo<BitmapImage> as new
   downcast helper
  2. Use IsA<BitmapImage>(element) in place of
   IsBitmapImage(element)

Bug: 891908
Change-Id: I1534b601cfae0f99adb15355f7f1042d1c889552
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2019644Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#744303}
parent 2e435943
...@@ -109,9 +109,10 @@ std::unique_ptr<DragImage> DragImage::Create( ...@@ -109,9 +109,10 @@ std::unique_ptr<DragImage> DragImage::Create(
return nullptr; return nullptr;
ImageOrientation orientation; ImageOrientation orientation;
auto* bitmap_image = DynamicTo<BitmapImage>(image);
if (should_respect_image_orientation == kRespectImageOrientation && if (should_respect_image_orientation == kRespectImageOrientation &&
image->IsBitmapImage()) bitmap_image)
orientation = ToBitmapImage(image)->CurrentFrameOrientation(); orientation = bitmap_image->CurrentFrameOrientation();
SkBitmap bm; SkBitmap bm;
paint_image = Image::ResizeAndOrientImage( paint_image = Image::ResizeAndOrientImage(
......
...@@ -1578,8 +1578,7 @@ bool CompositedLayerMapping::IsDirectlyCompositedImage() const { ...@@ -1578,8 +1578,7 @@ bool CompositedLayerMapping::IsDirectlyCompositedImage() const {
if (!cached_image->HasImage()) if (!cached_image->HasImage())
return false; return false;
Image* image = cached_image->GetImage(); if (!IsA<BitmapImage>(cached_image->GetImage()))
if (!image->IsBitmapImage())
return false; return false;
UseCounter::Count(GetLayoutObject().GetDocument(), UseCounter::Count(GetLayoutObject().GetDocument(),
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "third_party/blink/renderer/core/svg/graphics/svg_image.h" #include "third_party/blink/renderer/core/svg/graphics/svg_image.h"
#include "third_party/blink/renderer/core/timing/dom_window_performance.h" #include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/platform/geometry/int_rect.h" #include "third_party/blink/renderer/platform/geometry/int_rect.h"
#include "third_party/blink/renderer/platform/graphics/bitmap_image.h"
#include "third_party/blink/renderer/platform/graphics/image.h" #include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/paint/float_clip_rect.h" #include "third_party/blink/renderer/platform/graphics/paint/float_clip_rect.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h" #include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
...@@ -52,7 +53,7 @@ bool IsBackgroundImageContentful(const LayoutObject& object, ...@@ -52,7 +53,7 @@ bool IsBackgroundImageContentful(const LayoutObject& object,
} }
// Generated images are excluded here, as they are likely to serve for // Generated images are excluded here, as they are likely to serve for
// background purpose. // background purpose.
if (!image.IsBitmapImage() && !image.IsStaticBitmapImage() && if (!IsA<BitmapImage>(image) && !image.IsStaticBitmapImage() &&
!IsA<SVGImage>(image) && !image.IsPlaceholderImage()) !IsA<SVGImage>(image) && !image.IsPlaceholderImage())
return false; return false;
return true; return true;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "third_party/blink/renderer/platform/graphics/image_animation_policy.h" #include "third_party/blink/renderer/platform/graphics/image_animation_policy.h"
#include "third_party/blink/renderer/platform/image-decoders/image_animation.h" #include "third_party/blink/renderer/platform/image-decoders/image_animation.h"
#include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
#include "third_party/skia/include/core/SkRefCnt.h" #include "third_party/skia/include/core/SkRefCnt.h"
...@@ -184,7 +185,10 @@ class PLATFORM_EXPORT BitmapImage final : public Image { ...@@ -184,7 +185,10 @@ class PLATFORM_EXPORT BitmapImage final : public Image {
PaintImage::AnimationSequenceId reset_animation_sequence_id_ = 0; PaintImage::AnimationSequenceId reset_animation_sequence_id_ = 0;
}; };
DEFINE_IMAGE_TYPE_CASTS(BitmapImage); template <>
struct DowncastTraits<BitmapImage> {
static bool AllowFrom(const Image& image) { return image.IsBitmapImage(); }
};
} // namespace blink } // namespace blink
......
...@@ -648,9 +648,10 @@ void GraphicsLayer::SetContentsToImage( ...@@ -648,9 +648,10 @@ void GraphicsLayer::SetContentsToImage(
ImageOrientation image_orientation = kOriginTopLeft; ImageOrientation image_orientation = kOriginTopLeft;
SkMatrix matrix; SkMatrix matrix;
if (paint_image && image->IsBitmapImage() && auto* bitmap_image = DynamicTo<BitmapImage>(image);
if (paint_image && bitmap_image &&
respect_image_orientation == kRespectImageOrientation) { respect_image_orientation == kRespectImageOrientation) {
image_orientation = ToBitmapImage(image)->CurrentFrameOrientation(); image_orientation = bitmap_image->CurrentFrameOrientation();
image_size_ = IntSize(paint_image.width(), paint_image.height()); image_size_ = IntSize(paint_image.width(), paint_image.height());
if (image_orientation.UsesWidthAsHeight()) if (image_orientation.UsesWidthAsHeight())
image_size_ = image_size_.TransposedSize(); image_size_ = image_size_.TransposedSize();
......
...@@ -338,10 +338,9 @@ SkBitmap Image::AsSkBitmapForCurrentFrame( ...@@ -338,10 +338,9 @@ SkBitmap Image::AsSkBitmapForCurrentFrame(
if (!paint_image) if (!paint_image)
return {}; return {};
if (respect_image_orientation == kRespectImageOrientation && auto* bitmap_image = DynamicTo<BitmapImage>(this);
IsBitmapImage()) { if (respect_image_orientation == kRespectImageOrientation && bitmap_image) {
ImageOrientation orientation = ImageOrientation orientation = bitmap_image->CurrentFrameOrientation();
ToBitmapImage(this)->CurrentFrameOrientation();
paint_image = ResizeAndOrientImage(paint_image, orientation); paint_image = ResizeAndOrientImage(paint_image, orientation);
if (!paint_image) if (!paint_image)
return {}; return {};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment