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

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

Issue 2026803002: Avoid GPU readback in tex(Sub)Image2D(ImageBitmap) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address kbr@'s comments Created 4 years, 5 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
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 "platform/graphics/Image.h" 8 #include "platform/graphics/Image.h"
9 #include "public/platform/WebExternalTextureMailbox.h" 9 #include "public/platform/WebExternalTextureMailbox.h"
10 #include "third_party/khronos/GLES2/gl2.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
14 class WebGraphicsContext3DProvider;
15
13 class PLATFORM_EXPORT StaticBitmapImage final : public Image { 16 class PLATFORM_EXPORT StaticBitmapImage final : public Image {
14 public: 17 public:
15 ~StaticBitmapImage() override; 18 ~StaticBitmapImage() override;
16 19
17 bool currentFrameIsComplete() override { return true; } 20 bool currentFrameIsComplete() override { return true; }
18 21
19 static PassRefPtr<StaticBitmapImage> create(PassRefPtr<SkImage>); 22 static PassRefPtr<StaticBitmapImage> create(PassRefPtr<SkImage>);
20 static PassRefPtr<StaticBitmapImage> create(WebExternalTextureMailbox&); 23 static PassRefPtr<StaticBitmapImage> create(WebExternalTextureMailbox&);
21 virtual void destroyDecodedData() { } 24 virtual void destroyDecodedData() { }
22 virtual bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata); 25 virtual bool currentFrameKnownToBeOpaque(MetadataMode = UseCurrentMetadata);
23 virtual IntSize size() const; 26 virtual IntSize size() const;
24 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override; 27 void draw(SkCanvas*, const SkPaint&, const FloatRect& dstRect, const FloatRe ct& srcRect, RespectImageOrientationEnum, ImageClampingMode) override;
25 28
26 PassRefPtr<SkImage> imageForCurrentFrame() override; 29 PassRefPtr<SkImage> imageForCurrentFrame() override;
27 30
28 bool originClean() const { return m_isOriginClean; } 31 bool originClean() const { return m_isOriginClean; }
29 void setOriginClean(bool flag) { m_isOriginClean = flag; } 32 void setOriginClean(bool flag) { m_isOriginClean = flag; }
30 bool isPremultiplied() const { return m_isPremultiplied; } 33 bool isPremultiplied() const { return m_isPremultiplied; }
31 void setPremultiplied(bool flag) { m_isPremultiplied = flag; } 34 void setPremultiplied(bool flag) { m_isPremultiplied = flag; }
35 void copyToTexture(WebGraphicsContext3DProvider*, GLuint, GLenum, GLenum, bo ol);
36 bool isTextureBacked() override;
37 bool hasMailbox() { return m_mailbox.textureSize.width != 0 && m_mailbox.tex tureSize.height != 0; }
38
32 protected: 39 protected:
33 StaticBitmapImage(PassRefPtr<SkImage>); 40 StaticBitmapImage(PassRefPtr<SkImage>);
34 StaticBitmapImage(WebExternalTextureMailbox&); 41 StaticBitmapImage(WebExternalTextureMailbox&);
35 42
43 private:
44 GLuint switchStorageToSkImage(WebGraphicsContext3DProvider*);
45 bool switchStorageToMailbox(WebGraphicsContext3DProvider*);
46 GLuint textureIdForWebGL(WebGraphicsContext3DProvider*);
47
36 RefPtr<SkImage> m_image; 48 RefPtr<SkImage> m_image;
37 WebExternalTextureMailbox m_mailbox; 49 WebExternalTextureMailbox m_mailbox;
38 bool m_isOriginClean = true; 50 bool m_isOriginClean = true;
39 // The premultiply info is stored here because the SkImage API 51 // The premultiply info is stored here because the SkImage API
40 // doesn't expose this info. 52 // doesn't expose this info.
41 bool m_isPremultiplied = true; 53 bool m_isPremultiplied = true;
42 }; 54 };
43 55
44 } // namespace blink 56 } // namespace blink
45 57
46 #endif 58 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698