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

Unified 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 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/PlaceholderImage.h
diff --git a/third_party/WebKit/Source/platform/graphics/PlaceholderImage.h b/third_party/WebKit/Source/platform/graphics/PlaceholderImage.h
new file mode 100644
index 0000000000000000000000000000000000000000..a8673512a8f31bff34635380dbd894957c7507c8
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/PlaceholderImage.h
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PlaceholderImage_h
+#define PlaceholderImage_h
+
+#include "platform/SharedBuffer.h"
+#include "platform/geometry/IntSize.h"
+#include "platform/graphics/Image.h"
+#include "platform/graphics/ImageOrientation.h"
+#include "third_party/skia/include/core/SkImage.h"
+#include "third_party/skia/include/core/SkRefCnt.h"
+#include "wtf/PassRefPtr.h"
+
+class SkCanvas;
+class SkPaint;
+
+namespace blink {
+
+class FloatPoint;
+class FloatRect;
+class FloatSize;
+class GraphicsContext;
+class ImageObserver;
+
+// A generated placeholder image that shows a translucent gray rectangle.
+class PLATFORM_EXPORT PlaceholderImage final : public Image {
+ public:
+ static PassRefPtr<PlaceholderImage> create(ImageObserver* observer,
+ const IntSize& size) {
+ return adoptRef(new PlaceholderImage(observer, size));
+ }
+
+ ~PlaceholderImage() override;
+
+ IntSize size() const override { return m_size; }
+
+ sk_sp<SkImage> imageForCurrentFrame() override;
+
+ void draw(SkCanvas*,
+ const SkPaint&,
+ const FloatRect& destRect,
+ const FloatRect& srcRect,
+ RespectImageOrientationEnum,
+ ImageClampingMode) override;
+
+ void drawPattern(GraphicsContext&,
+ const FloatRect& srcRect,
+ const FloatSize& scale,
+ const FloatPoint& phase,
+ SkXfermode::Mode,
+ const FloatRect& destRect,
+ const FloatSize& repeatSpacing) override;
+
+ void destroyDecodedData() override;
+
+ private:
+ PlaceholderImage(ImageObserver* observer, const IntSize& size)
+ : Image(observer), m_size(size) {}
+
+ bool currentFrameHasSingleSecurityOrigin() const override { return true; }
+
+ bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override {
+ // Placeholder images are translucent.
+ return false;
+ }
+
+ IntSize m_size;
+ // Lazily initialized.
+ sk_sp<SkImage> m_imageForCurrentFrame;
+};
+
+} // namespace blink
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698