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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/PlaceholderImage.h

Issue 2423683002: Add Blink support for showing image placeholders using range requests. (Closed)
Patch Set: Addressed comments and fixed bugs Created 4 years, 2 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
(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/SharedBuffer.h"
9 #include "platform/geometry/IntSize.h"
10 #include "platform/graphics/Image.h"
11 #include "platform/graphics/ImageOrientation.h"
12 #include "third_party/skia/include/core/SkImage.h"
13 #include "third_party/skia/include/core/SkRefCnt.h"
14 #include "wtf/PassRefPtr.h"
15
16 class SkCanvas;
17 class SkPaint;
18
19 namespace blink {
20
21 class FloatPoint;
22 class FloatRect;
23 class FloatSize;
24 class GraphicsContext;
25 class ImageObserver;
26
27 // A generated placeholder image that shows a translucent gray rectangle.
28 class PLATFORM_EXPORT PlaceholderImage final : public Image {
29 public:
30 static PassRefPtr<PlaceholderImage> create(ImageObserver* observer,
31 const IntSize& size) {
32 return adoptRef(new PlaceholderImage(observer, size));
33 }
34
35 ~PlaceholderImage() override;
36
37 IntSize size() const override { return m_size; }
38
39 sk_sp<SkImage> imageForCurrentFrame() override;
40
41 void draw(SkCanvas*,
42 const SkPaint&,
43 const FloatRect& destRect,
44 const FloatRect& srcRect,
45 RespectImageOrientationEnum,
46 ImageClampingMode) override;
47
48 void drawPattern(GraphicsContext&,
49 const FloatRect& srcRect,
50 const FloatSize& scale,
51 const FloatPoint& phase,
52 SkXfermode::Mode,
53 const FloatRect& destRect,
54 const FloatSize& repeatSpacing) override;
55
56 void destroyDecodedData() override;
57
58 private:
59 PlaceholderImage(ImageObserver* observer, const IntSize& size)
60 : Image(observer), m_size(size) {}
61
62 bool currentFrameHasSingleSecurityOrigin() const override { return true; }
63
64 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override {
65 // Placeholder images are translucent.
66 return false;
67 }
68
69 IntSize m_size;
70 // Lazily initialized.
71 sk_sp<SkImage> m_imageForCurrentFrame;
72 };
73
74 } // namespace blink
75
76 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698