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

Unified Diff: third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h

Issue 1755163003: CL for perf tryjob on mac Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/Canvas2DLayerBridge.h
diff --git a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h
index d2dfc7e4d1f51a056f33e4b19e32b428bdb8f981..364381f87f78e7cef401835bac83c52228c55c14 100644
--- a/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h
+++ b/third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridge.h
@@ -40,6 +40,7 @@
#include "wtf/PassOwnPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
+#include "wtf/Vector.h"
#include "wtf/WeakPtr.h"
class SkPictureRecorder;
@@ -126,6 +127,35 @@ public:
void setLoggerForTesting(PassOwnPtr<Logger>);
private:
+ // All information associated with a CHROMIUM image.
+ struct ImageInfo {
+ ImageInfo() {}
+ ImageInfo(GLuint imageId, GLuint textureId);
+
+ // Whether this structure holds references to a CHROMIUM image.
+ bool empty();
+
+ // The id of the CHROMIUM image.
+ GLuint m_imageId = 0;
+
+ // The id of the texture bound to the CHROMIUM image.
+ GLuint m_textureId = 0;
+ };
+
+ struct MailboxInfo {
+ DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
+ WebExternalTextureMailbox m_mailbox;
+ RefPtr<SkImage> m_image;
+ RefPtr<Canvas2DLayerBridge> m_parentLayerBridge;
+
+ // If this mailbox wraps an IOSurface-backed texture, the ids of the
+ // CHROMIUM image and the texture.
+ ImageInfo m_imageInfo;
+
+ MailboxInfo(const MailboxInfo&);
+ MailboxInfo() {}
+ };
+
Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, const IntSize&, int msaaSampleCount, OpacityMode, AccelerationMode);
WebGraphicsContext3D* context();
void startRecording();
@@ -141,6 +171,36 @@ private:
SkSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration);
bool shouldAccelerate(AccelerationHint) const;
+ // Returns the GL filter associated with |m_filterQuality|.
+ GLenum getGLFilter();
+
+ // Creates an IOSurface-backed texture. Copies |image| into the texture.
+ // Prepares a mailbox from the texture. Stores all information in a newly
+ // created MailboxInfo, which resides in |m_mailboxes|. Returns whether the
+ // mailbox was successfully prepared. |mailbox| is an out parameter only
+ // populated on success.
+ bool prepareIOSurfaceMailboxFromImage(RefPtr<SkImage>, WebExternalTextureMailbox*);
+
+ // Creates an IOSurface-backed texture. Returns an ImageInfo, which is empty
+ // on failure. The caller takes ownership of both the texture and the image.
+ ImageInfo createIOSurfaceBackedTexture();
+
+ // Prepends a new MailboxInfo object to |m_mailboxes|, and returns a
+ // reference. The reference is no longer valid after |m_mailboxes| is
+ // mutated.
+ MailboxInfo& createMailboxInfo();
+
+ // Returns whether the mailbox was successfully prepared from the SkImage.
+ // The mailbox is an out parameter only populated on success.
+ bool prepareMailboxFromImage(RefPtr<SkImage>, WebExternalTextureMailbox*);
+
+ // Resets Skia's texture bindings. This method should be called after
+ // changing texture bindings.
+ void resetSkiaTextureBinding();
+
+ // Releases all resources associated with a CHROMIUM image.
+ void deleteCHROMIUMImage(ImageInfo);
+
OwnPtr<SkPictureRecorder> m_recorder;
RefPtr<SkSurface> m_surface;
RefPtr<SkImage> m_hibernationImage;
@@ -166,16 +226,6 @@ private:
friend class Canvas2DLayerBridgeTest;
- struct MailboxInfo {
- DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
- WebExternalTextureMailbox m_mailbox;
- RefPtr<SkImage> m_image;
- RefPtr<Canvas2DLayerBridge> m_parentLayerBridge;
-
- MailboxInfo(const MailboxInfo&);
- MailboxInfo() {}
- };
-
uint32_t m_lastImageId;
enum {
@@ -188,8 +238,13 @@ private:
GLenum m_lastFilter;
AccelerationMode m_accelerationMode;
OpacityMode m_opacityMode;
- IntSize m_size;
+ const IntSize m_size;
int m_recordingPixelCount;
+
+ // Each element in this vector represents an IOSurface backed texture that
+ // is ready to be reused.
+ // Elements in this vector can safely be purged in low memory conditions.
+ Vector<ImageInfo> m_imageInfoCache;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698