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

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

Issue 2455983005: Refactor AcceleratedStaticBitmapImage (Closed)
Patch Set: WeakPtr, still figuring out why one layout test timed out Created 4 years, 1 month 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef StaticBitmapImage_h 5 #ifndef StaticBitmapImage_h
6 #define StaticBitmapImage_h 6 #define StaticBitmapImage_h
7 7
8 #include "gpu/command_buffer/common/mailbox.h" 8 #include "gpu/command_buffer/common/mailbox.h"
9 #include "gpu/command_buffer/common/sync_token.h" 9 #include "gpu/command_buffer/common/sync_token.h"
10 #include "platform/graphics/Image.h" 10 #include "platform/graphics/Image.h"
11 #include "third_party/khronos/GLES2/gl2.h" 11 #include "third_party/khronos/GLES2/gl2.h"
12 #include "third_party/skia/include/core/SkRefCnt.h" 12 #include "third_party/skia/include/core/SkRefCnt.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class WebGraphicsContext3DProvider; 16 class WebGraphicsContext3DProvider;
17 17
18 class PLATFORM_EXPORT StaticBitmapImage : public Image { 18 class PLATFORM_EXPORT StaticBitmapImage : public Image {
19 public: 19 public:
20 ~StaticBitmapImage() override; 20 static PassRefPtr<StaticBitmapImage> create(sk_sp<SkImage>);
21 21
22 bool currentFrameIsComplete() override { return true; } 22 // Methods overrided by all sub-classes
23 23 virtual ~StaticBitmapImage() {}
24 static PassRefPtr<StaticBitmapImage> create(sk_sp<SkImage>); 24 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) = 0;
25 void destroyDecodedData() override {} 25 sk_sp<SkImage> imageForCurrentFrame() = 0;
26 bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata) override; 26 bool isTextureBacked() = 0;
27 IntSize size() const override;
28 void draw(SkCanvas*, 27 void draw(SkCanvas*,
29 const SkPaint&, 28 const SkPaint&,
30 const FloatRect& dstRect, 29 const FloatRect& dstRect,
31 const FloatRect& srcRect, 30 const FloatRect& srcRect,
32 RespectImageOrientationEnum, 31 RespectImageOrientationEnum,
33 ImageClampingMode) override; 32 ImageClampingMode) = 0;
33 virtual bool originClean() const = 0;
34 virtual void setOriginClean(bool flag) = 0;
35 virtual bool isPremultiplied() const = 0;
36 virtual void setPremultiplied(bool flag) = 0;
34 37
35 sk_sp<SkImage> imageForCurrentFrame() override; 38 // Methods have common implementation for all sub-classes
39 bool currentFrameIsComplete() override { return true; }
40 void destroyDecodedData() {}
36 41
37 bool originClean() const { return m_isOriginClean; } 42 // Methods that have a default implementation, and overrided by only one
38 void setOriginClean(bool flag) { m_isOriginClean = flag; } 43 // sub-class
39 bool isPremultiplied() const { return m_isPremultiplied; } 44 virtual bool hasMailbox() { return false; }
40 void setPremultiplied(bool flag) { m_isPremultiplied = flag; } 45 virtual void transfer() {}
41 bool isTextureBacked() override; 46
47 // Methods overrided by AcceleratedStaticBitmapImage only
42 virtual void copyToTexture(WebGraphicsContext3DProvider*, 48 virtual void copyToTexture(WebGraphicsContext3DProvider*,
43 GLuint, 49 GLuint,
44 GLenum, 50 GLenum,
45 GLenum, 51 GLenum,
46 bool) { 52 bool) {
47 NOTREACHED(); 53 NOTREACHED();
48 } 54 }
49 virtual bool hasMailbox() { return false; } 55 virtual void ensureMailbox() { NOTREACHED(); }
50 virtual void transfer() {} 56 virtual gpu::Mailbox mailbox() {
51 57 NOTREACHED();
52 virtual gpu::Mailbox getMailbox() { return gpu::Mailbox(); } 58 return gpu::Mailbox();
53 virtual gpu::SyncToken getSyncToken() { return gpu::SyncToken(); } 59 }
54 virtual void ensureMailbox() {} 60 virtual gpu::SyncToken syncToken() {
61 NOTREACHED();
62 return gpu::SyncToken();
63 }
64 virtual void updateSyncToken(gpu::SyncToken) { NOTREACHED(); }
55 65
56 protected: 66 protected:
57 StaticBitmapImage(sk_sp<SkImage>); 67 // Helper for sub-classes
58 StaticBitmapImage(); // empty constructor for derived class. 68 void drawHelper(SkCanvas*,
59 sk_sp<SkImage> m_image; 69 const SkPaint&,
60 70 const FloatRect&,
61 private: 71 const FloatRect&,
62 bool m_isOriginClean = true; 72 ImageClampingMode,
63 // The premultiply info is stored here because the SkImage API 73 sk_sp<SkImage>);
64 // doesn't expose this info.
65 bool m_isPremultiplied = true;
66 }; 74 };
67 75
68 } // namespace blink 76 } // namespace blink
69 77
70 #endif 78 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698