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

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

Issue 2212163002: Add some plumbing for the color management of canvases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 class PLATFORM_EXPORT Canvas2DLayerBridge : public WebExternalTextureLayerClient , public WebThread::TaskObserver, public RefCounted<Canvas2DLayerBridge> { 79 class PLATFORM_EXPORT Canvas2DLayerBridge : public WebExternalTextureLayerClient , public WebThread::TaskObserver, public RefCounted<Canvas2DLayerBridge> {
80 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); 80 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge);
81 public: 81 public:
82 enum AccelerationMode { 82 enum AccelerationMode {
83 DisableAcceleration, 83 DisableAcceleration,
84 EnableAcceleration, 84 EnableAcceleration,
85 ForceAccelerationForTesting, 85 ForceAccelerationForTesting,
86 }; 86 };
87 87
88 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, int msaaSample Count, OpacityMode, AccelerationMode); 88 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, int msaaSample Count, OpacityMode, AccelerationMode, sk_sp<SkColorSpace>);
89 89
90 ~Canvas2DLayerBridge() override; 90 ~Canvas2DLayerBridge() override;
91 91
92 // WebExternalTextureLayerClient implementation. 92 // WebExternalTextureLayerClient implementation.
93 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override ; 93 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override ;
94 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource) ov erride; 94 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource) ov erride;
95 95
96 // ImageBufferSurface implementation 96 // ImageBufferSurface implementation
97 void finalizeFrame(const FloatRect &dirtyRect); 97 void finalizeFrame(const FloatRect &dirtyRect);
98 void willWritePixels(); 98 void willWritePixels();
(...skipping 12 matching lines...) Expand all
111 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in t x, int y); 111 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in t x, int y);
112 void flush(); 112 void flush();
113 void flushGpu(); 113 void flushGpu();
114 void prepareSurfaceForPaintingIfNeeded(); 114 void prepareSurfaceForPaintingIfNeeded();
115 bool isHidden() { return m_isHidden; } 115 bool isHidden() { return m_isHidden; }
116 OpacityMode opacityMode() { return m_opacityMode; } 116 OpacityMode opacityMode() { return m_opacityMode; }
117 117
118 void beginDestruction(); 118 void beginDestruction();
119 void hibernate(); 119 void hibernate();
120 bool isHibernating() const { return m_hibernationImage.get(); } 120 bool isHibernating() const { return m_hibernationImage.get(); }
121 sk_sp<SkColorSpace> colorSpace() const { return m_colorSpace; }
121 122
122 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint, SnapshotReason); 123 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint, SnapshotReason);
123 124
124 // The values of the enum entries must not change because they are used for 125 // The values of the enum entries must not change because they are used for
125 // usage metrics histograms. New values can be added to the end. 126 // usage metrics histograms. New values can be added to the end.
126 enum HibernationEvent { 127 enum HibernationEvent {
127 HibernationScheduled = 0, 128 HibernationScheduled = 0,
128 HibernationAbortedDueToDestructionWhileHibernatePending = 1, 129 HibernationAbortedDueToDestructionWhileHibernatePending = 1,
129 HibernationAbortedDueToPendingDestruction = 2, 130 HibernationAbortedDueToPendingDestruction = 2,
130 HibernationAbortedDueToVisibilityChange = 3, 131 HibernationAbortedDueToVisibilityChange = 3,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 #if USE_IOSURFACE_FOR_2D_CANVAS 177 #if USE_IOSURFACE_FOR_2D_CANVAS
177 // If this mailbox wraps an IOSurface-backed texture, the ids of the 178 // If this mailbox wraps an IOSurface-backed texture, the ids of the
178 // CHROMIUM image and the texture. 179 // CHROMIUM image and the texture.
179 ImageInfo m_imageInfo; 180 ImageInfo m_imageInfo;
180 #endif // USE_IOSURFACE_FOR_2D_CANVAS 181 #endif // USE_IOSURFACE_FOR_2D_CANVAS
181 182
182 MailboxInfo(const MailboxInfo&); 183 MailboxInfo(const MailboxInfo&);
183 MailboxInfo() {} 184 MailboxInfo() {}
184 }; 185 };
185 186
186 Canvas2DLayerBridge(std::unique_ptr<WebGraphicsContext3DProvider>, const Int Size&, int msaaSampleCount, OpacityMode, AccelerationMode); 187 Canvas2DLayerBridge(std::unique_ptr<WebGraphicsContext3DProvider>, const Int Size&, int msaaSampleCount, OpacityMode, AccelerationMode, sk_sp<SkColorSpace>);
187 gpu::gles2::GLES2Interface* contextGL(); 188 gpu::gles2::GLES2Interface* contextGL();
188 void startRecording(); 189 void startRecording();
189 void skipQueuedDrawCommands(); 190 void skipQueuedDrawCommands();
190 void flushRecordingOnly(); 191 void flushRecordingOnly();
191 void unregisterTaskObserver(); 192 void unregisterTaskObserver();
192 void reportSurfaceCreationFailure(); 193 void reportSurfaceCreationFailure();
193 194
194 // WebThread::TaskOberver implementation 195 // WebThread::TaskOberver implementation
195 void willProcessTask() override; 196 void willProcessTask() override;
196 void didProcessTask() override; 197 void didProcessTask() override;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // We should normally not have more that two active mailboxes at a time, 265 // We should normally not have more that two active mailboxes at a time,
265 // but sometime we may have three due to the async nature of mailbox han dling. 266 // but sometime we may have three due to the async nature of mailbox han dling.
266 MaxActiveMailboxes = 3, 267 MaxActiveMailboxes = 3,
267 }; 268 };
268 269
269 Deque<MailboxInfo, MaxActiveMailboxes> m_mailboxes; 270 Deque<MailboxInfo, MaxActiveMailboxes> m_mailboxes;
270 GLenum m_lastFilter; 271 GLenum m_lastFilter;
271 AccelerationMode m_accelerationMode; 272 AccelerationMode m_accelerationMode;
272 OpacityMode m_opacityMode; 273 OpacityMode m_opacityMode;
273 const IntSize m_size; 274 const IntSize m_size;
275 sk_sp<SkColorSpace> m_colorSpace;
274 int m_recordingPixelCount; 276 int m_recordingPixelCount;
275 277
276 #if USE_IOSURFACE_FOR_2D_CANVAS 278 #if USE_IOSURFACE_FOR_2D_CANVAS
277 // Each element in this vector represents an IOSurface backed texture that 279 // Each element in this vector represents an IOSurface backed texture that
278 // is ready to be reused. 280 // is ready to be reused.
279 // Elements in this vector can safely be purged in low memory conditions. 281 // Elements in this vector can safely be purged in low memory conditions.
280 Vector<ImageInfo> m_imageInfoCache; 282 Vector<ImageInfo> m_imageInfoCache;
281 #endif // USE_IOSURFACE_FOR_2D_CANVAS 283 #endif // USE_IOSURFACE_FOR_2D_CANVAS
282 }; 284 };
283 285
284 } // namespace blink 286 } // namespace blink
285 287
286 #endif 288 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698