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

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

Issue 1757033002: CL for perf tryjob on mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 class PLATFORM_EXPORT Logger { 119 class PLATFORM_EXPORT Logger {
120 public: 120 public:
121 virtual void reportHibernationEvent(HibernationEvent); 121 virtual void reportHibernationEvent(HibernationEvent);
122 virtual void didStartHibernating() { } 122 virtual void didStartHibernating() { }
123 virtual ~Logger() { } 123 virtual ~Logger() { }
124 }; 124 };
125 125
126 void setLoggerForTesting(PassOwnPtr<Logger>); 126 void setLoggerForTesting(PassOwnPtr<Logger>);
127 127
128 private: 128 private:
129 struct MailboxInfo {
130 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
131 WebExternalTextureMailbox m_mailbox;
132 RefPtr<SkImage> m_image;
133 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge;
134
135 // If this mailbox wraps an IOSurface-backed texture, the ids of the
136 // CHROMIUM image and the texture.
137 GLuint m_CHROMIUMImageId = 0;
138 GLuint m_textureId = 0;
139
140 MailboxInfo(const MailboxInfo&);
141 MailboxInfo() {}
142 };
143
129 Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, const IntSize& , int msaaSampleCount, OpacityMode, AccelerationMode); 144 Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, const IntSize& , int msaaSampleCount, OpacityMode, AccelerationMode);
130 WebGraphicsContext3D* context(); 145 WebGraphicsContext3D* context();
131 void startRecording(); 146 void startRecording();
132 void skipQueuedDrawCommands(); 147 void skipQueuedDrawCommands();
133 void flushRecordingOnly(); 148 void flushRecordingOnly();
134 void unregisterTaskObserver(); 149 void unregisterTaskObserver();
135 void reportSurfaceCreationFailure(); 150 void reportSurfaceCreationFailure();
136 151
137 // WebThread::TaskOberver implementation 152 // WebThread::TaskOberver implementation
138 void willProcessTask() override; 153 void willProcessTask() override;
139 void didProcessTask() override; 154 void didProcessTask() override;
140 155
141 SkSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration); 156 SkSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration);
142 bool shouldAccelerate(AccelerationHint) const; 157 bool shouldAccelerate(AccelerationHint) const;
143 158
159 // Returns the GL filter associated with |m_filterQuality|.
160 GLenum getGLFilter();
161
162 // Creates an IOSurface-backed texture. Copies |image| into the texture.
163 // Prepares a mailbox from the texture. Stores all information in a newly
164 // created MailboxInfo, which resides in |m_mailboxes|. Returns whether the
165 // mailbox was successfully prepared. |mailbox| is an out parameter only
166 // populated on success.
167 bool prepareIOSurfaceMailboxFromImage(RefPtr<SkImage>&, WebExternalTextureMa ilbox*);
168
169 // Creates an IOSurface-backed texture. Returns whether the texture ewas
170 // successfully created. |texture| and |imageId| are out parameters. The
171 // caller takes ownership of both the texture and the image.
172 bool createIOSurfaceBackedTexture(GLuint* texture, GLuint* imageId);
173
174 // Prepends a new MailboxInfo object to |m_mailboxes|, and returns a
175 // reference. The reference is no longer valid after |m_mailboxes| is
176 // mutated.
177 MailboxInfo& createMailboxInfo();
178
179 // Returns whether the mailbox was successfully prepared from the SkImage.
180 // The mailbox is an out parameter only populated on success.
181 bool prepareMailboxFromImage(RefPtr<SkImage>&, WebExternalTextureMailbox*);
182
144 OwnPtr<SkPictureRecorder> m_recorder; 183 OwnPtr<SkPictureRecorder> m_recorder;
145 RefPtr<SkSurface> m_surface; 184 RefPtr<SkSurface> m_surface;
146 RefPtr<SkImage> m_hibernationImage; 185 RefPtr<SkImage> m_hibernationImage;
147 int m_initialSurfaceSaveCount; 186 int m_initialSurfaceSaveCount;
148 OwnPtr<WebExternalTextureLayer> m_layer; 187 OwnPtr<WebExternalTextureLayer> m_layer;
149 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; 188 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider;
150 OwnPtr<SharedContextRateLimiter> m_rateLimiter; 189 OwnPtr<SharedContextRateLimiter> m_rateLimiter;
151 OwnPtr<Logger> m_logger; 190 OwnPtr<Logger> m_logger;
152 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory; 191 WeakPtrFactory<Canvas2DLayerBridge> m_weakPtrFactory;
153 ImageBuffer* m_imageBuffer; 192 ImageBuffer* m_imageBuffer;
154 int m_msaaSampleCount; 193 int m_msaaSampleCount;
155 size_t m_bytesAllocated; 194 size_t m_bytesAllocated;
156 bool m_haveRecordedDrawCommands; 195 bool m_haveRecordedDrawCommands;
157 bool m_destructionInProgress; 196 bool m_destructionInProgress;
158 SkFilterQuality m_filterQuality; 197 SkFilterQuality m_filterQuality;
159 bool m_isHidden; 198 bool m_isHidden;
160 bool m_isDeferralEnabled; 199 bool m_isDeferralEnabled;
161 bool m_isRegisteredTaskObserver; 200 bool m_isRegisteredTaskObserver;
162 bool m_renderingTaskCompletedForCurrentFrame; 201 bool m_renderingTaskCompletedForCurrentFrame;
163 bool m_softwareRenderingWhileHidden; 202 bool m_softwareRenderingWhileHidden;
164 bool m_surfaceCreationFailedAtLeastOnce = false; 203 bool m_surfaceCreationFailedAtLeastOnce = false;
165 bool m_hibernationScheduled = false; 204 bool m_hibernationScheduled = false;
166 205
167 friend class Canvas2DLayerBridgeTest; 206 friend class Canvas2DLayerBridgeTest;
168 207
169 struct MailboxInfo {
170 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
171 WebExternalTextureMailbox m_mailbox;
172 RefPtr<SkImage> m_image;
173 RefPtr<Canvas2DLayerBridge> m_parentLayerBridge;
174
175 MailboxInfo(const MailboxInfo&);
176 MailboxInfo() {}
177 };
178
179 uint32_t m_lastImageId; 208 uint32_t m_lastImageId;
180 209
181 enum { 210 enum {
182 // We should normally not have more that two active mailboxes at a time, 211 // We should normally not have more that two active mailboxes at a time,
183 // but sometime we may have three due to the async nature of mailbox han dling. 212 // but sometime we may have three due to the async nature of mailbox han dling.
184 MaxActiveMailboxes = 3, 213 MaxActiveMailboxes = 3,
185 }; 214 };
186 215
187 Deque<MailboxInfo, MaxActiveMailboxes> m_mailboxes; 216 Deque<MailboxInfo, MaxActiveMailboxes> m_mailboxes;
188 GLenum m_lastFilter; 217 GLenum m_lastFilter;
189 AccelerationMode m_accelerationMode; 218 AccelerationMode m_accelerationMode;
190 OpacityMode m_opacityMode; 219 OpacityMode m_opacityMode;
191 IntSize m_size; 220 IntSize m_size;
192 int m_recordingPixelCount; 221 int m_recordingPixelCount;
193 }; 222 };
194 223
195 } // namespace blink 224 } // namespace blink
196 225
197 #endif 226 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698