OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PlaceholderImage_h |
| 6 #define PlaceholderImage_h |
| 7 |
| 8 #include "platform/geometry/IntSize.h" |
| 9 #include "platform/graphics/Image.h" |
| 10 #include "platform/graphics/ImageOrientation.h" |
| 11 #include "third_party/skia/include/core/SkRefCnt.h" |
| 12 #include "wtf/PassRefPtr.h" |
| 13 |
| 14 class SkCanvas; |
| 15 class SkImage; |
| 16 class SkPaint; |
| 17 |
| 18 namespace blink { |
| 19 |
| 20 class FloatPoint; |
| 21 class FloatRect; |
| 22 class FloatSize; |
| 23 class GraphicsContext; |
| 24 class ImageObserver; |
| 25 |
| 26 // A generated placeholder image that shows a translucent gray rectangle. |
| 27 class PLATFORM_EXPORT PlaceholderImage final : public Image { |
| 28 public: |
| 29 static PassRefPtr<PlaceholderImage> create(ImageObserver* observer, |
| 30 const IntSize& size) { |
| 31 return adoptRef(new PlaceholderImage(observer, size)); |
| 32 } |
| 33 |
| 34 ~PlaceholderImage() override; |
| 35 |
| 36 IntSize size() const override { return m_size; } |
| 37 |
| 38 sk_sp<SkImage> imageForCurrentFrame() override; |
| 39 |
| 40 void draw(SkCanvas*, |
| 41 const SkPaint&, |
| 42 const FloatRect& destRect, |
| 43 const FloatRect& srcRect, |
| 44 RespectImageOrientationEnum, |
| 45 ImageClampingMode) override; |
| 46 |
| 47 void drawPattern(GraphicsContext&, |
| 48 const FloatRect& srcRect, |
| 49 const FloatSize& scale, |
| 50 const FloatPoint& phase, |
| 51 SkXfermode::Mode, |
| 52 const FloatRect& destRect, |
| 53 const FloatSize& repeatSpacing) override; |
| 54 |
| 55 private: |
| 56 PlaceholderImage(ImageObserver* observer, const IntSize& size) |
| 57 : Image(observer), m_size(size) {} |
| 58 |
| 59 bool currentFrameHasSingleSecurityOrigin() const override { return true; } |
| 60 |
| 61 // There's no decoded data to worry about. |
| 62 void destroyDecodedData() override {} |
| 63 |
| 64 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override { |
| 65 // Placeholder images are translucent. |
| 66 return false; |
| 67 } |
| 68 |
| 69 IntSize m_size; |
| 70 }; |
| 71 |
| 72 } // namespace blink |
| 73 |
| 74 #endif |
OLD | NEW |