| OLD | NEW |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 class Canvas2DLayerBridgeTest; | 47 class Canvas2DLayerBridgeTest; |
| 48 class ImageBuffer; | 48 class ImageBuffer; |
| 49 class WebGraphicsContext3D; | 49 class WebGraphicsContext3D; |
| 50 class WebGraphicsContext3DProvider; | 50 class WebGraphicsContext3DProvider; |
| 51 class SharedContextRateLimiter; | 51 class SharedContextRateLimiter; |
| 52 | 52 |
| 53 class PLATFORM_EXPORT Canvas2DLayerBridge : public WebExternalTextureLayerClient
, public WebThread::TaskObserver, public RefCounted<Canvas2DLayerBridge> { | 53 class PLATFORM_EXPORT Canvas2DLayerBridge : public WebExternalTextureLayerClient
, public WebThread::TaskObserver, public RefCounted<Canvas2DLayerBridge> { |
| 54 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); | 54 WTF_MAKE_NONCOPYABLE(Canvas2DLayerBridge); |
| 55 public: | 55 public: |
| 56 enum AccelerationMode { | 56 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, OpacityMode, i
nt msaaSampleCount); |
| 57 DisableAcceleration, | |
| 58 EnableAcceleration, | |
| 59 ForceAccelerationForTesting, | |
| 60 }; | |
| 61 | |
| 62 static PassRefPtr<Canvas2DLayerBridge> create(const IntSize&, int msaaSample
Count, OpacityMode, AccelerationMode); | |
| 63 | 57 |
| 64 ~Canvas2DLayerBridge() override; | 58 ~Canvas2DLayerBridge() override; |
| 65 | 59 |
| 66 // WebExternalTextureLayerClient implementation. | 60 // WebExternalTextureLayerClient implementation. |
| 67 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override
; | 61 bool prepareMailbox(WebExternalTextureMailbox*, WebExternalBitmap*) override
; |
| 68 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource) ov
erride; | 62 void mailboxReleased(const WebExternalTextureMailbox&, bool lostResource) ov
erride; |
| 69 | 63 |
| 70 // ImageBufferSurface implementation | 64 // ImageBufferSurface implementation |
| 71 void finalizeFrame(const FloatRect &dirtyRect); | 65 void finalizeFrame(const FloatRect &dirtyRect); |
| 72 void willWritePixels(); | 66 void willWritePixels(); |
| 73 void willOverwriteAllPixels(); | 67 void willOverwriteAllPixels(); |
| 74 void willOverwriteCanvas(); | 68 void willOverwriteCanvas(); |
| 75 SkCanvas* canvas(); | 69 SkCanvas* canvas(); |
| 76 void disableDeferral(); | 70 void disableDeferral(); |
| 77 bool checkSurfaceValid(); | 71 bool checkSurfaceValid(); |
| 78 bool restoreSurface(); | 72 bool restoreSurface(); |
| 79 WebLayer* layer() const; | 73 WebLayer* layer() const; |
| 80 bool isAccelerated() const; | 74 bool isAccelerated() const { return true; } |
| 81 void setFilterQuality(SkFilterQuality); | 75 void setFilterQuality(SkFilterQuality); |
| 82 void setIsHidden(bool); | 76 void setIsHidden(bool); |
| 83 void setImageBuffer(ImageBuffer*); | 77 void setImageBuffer(ImageBuffer*); |
| 84 void didDraw(const FloatRect&); | 78 void didDraw(const FloatRect&); |
| 85 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in
t x, int y); | 79 bool writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, in
t x, int y); |
| 86 void flush(); | 80 void flush(); |
| 87 void flushGpu(); | 81 void flushGpu(); |
| 88 void prepareSurfaceForPaintingIfNeeded(); | |
| 89 bool isHidden() { return m_isHidden; } | 82 bool isHidden() { return m_isHidden; } |
| 90 | 83 |
| 91 void beginDestruction(); | 84 void beginDestruction(); |
| 92 | 85 |
| 93 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint); | 86 PassRefPtr<SkImage> newImageSnapshot(); |
| 94 | 87 |
| 95 private: | 88 private: |
| 96 Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, const IntSize&
, int msaaSampleCount, OpacityMode, AccelerationMode); | 89 Canvas2DLayerBridge(PassOwnPtr<WebGraphicsContext3DProvider>, PassRefPtr<SkS
urface>, int, OpacityMode); |
| 97 WebGraphicsContext3D* context(); | 90 WebGraphicsContext3D* context(); |
| 98 void startRecording(); | 91 void startRecording(); |
| 99 void skipQueuedDrawCommands(); | 92 void skipQueuedDrawCommands(); |
| 100 void flushRecordingOnly(); | 93 void flushRecordingOnly(); |
| 101 void unregisterTaskObserver(); | 94 void unregisterTaskObserver(); |
| 102 | 95 |
| 103 // WebThread::TaskOberver implementation | 96 // WebThread::TaskOberver implementation |
| 104 void willProcessTask() override; | 97 void willProcessTask() override; |
| 105 void didProcessTask() override; | 98 void didProcessTask() override; |
| 106 | 99 |
| 107 SkSurface* getOrCreateSurface(AccelerationHint = PreferAcceleration); | |
| 108 bool shouldAccelerate(AccelerationHint) const; | |
| 109 | |
| 110 OwnPtr<SkPictureRecorder> m_recorder; | 100 OwnPtr<SkPictureRecorder> m_recorder; |
| 111 RefPtr<SkSurface> m_surface; | 101 RefPtr<SkSurface> m_surface; |
| 112 int m_initialSurfaceSaveCount; | 102 int m_initialSurfaceSaveCount; |
| 113 OwnPtr<WebExternalTextureLayer> m_layer; | 103 OwnPtr<WebExternalTextureLayer> m_layer; |
| 114 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; | 104 OwnPtr<WebGraphicsContext3DProvider> m_contextProvider; |
| 115 OwnPtr<SharedContextRateLimiter> m_rateLimiter; | 105 OwnPtr<SharedContextRateLimiter> m_rateLimiter; |
| 116 ImageBuffer* m_imageBuffer; | 106 ImageBuffer* m_imageBuffer; |
| 117 int m_msaaSampleCount; | 107 int m_msaaSampleCount; |
| 118 size_t m_bytesAllocated; | 108 size_t m_bytesAllocated; |
| 119 bool m_haveRecordedDrawCommands; | 109 bool m_haveRecordedDrawCommands; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 138 uint32_t m_lastImageId; | 128 uint32_t m_lastImageId; |
| 139 | 129 |
| 140 enum { | 130 enum { |
| 141 // We should normally not have more that two active mailboxes at a time, | 131 // We should normally not have more that two active mailboxes at a time, |
| 142 // but sometime we may have three due to the async nature of mailbox han
dling. | 132 // but sometime we may have three due to the async nature of mailbox han
dling. |
| 143 MaxActiveMailboxes = 3, | 133 MaxActiveMailboxes = 3, |
| 144 }; | 134 }; |
| 145 | 135 |
| 146 Deque<MailboxInfo, MaxActiveMailboxes> m_mailboxes; | 136 Deque<MailboxInfo, MaxActiveMailboxes> m_mailboxes; |
| 147 GLenum m_lastFilter; | 137 GLenum m_lastFilter; |
| 148 AccelerationMode m_accelerationMode; | |
| 149 OpacityMode m_opacityMode; | 138 OpacityMode m_opacityMode; |
| 150 IntSize m_size; | 139 IntSize m_size; |
| 151 int m_recordingPixelCount; | 140 int m_recordingPixelCount; |
| 152 }; | 141 }; |
| 153 | 142 |
| 154 } // namespace blink | 143 } // namespace blink |
| 155 | 144 |
| 156 #endif | 145 #endif |
| OLD | NEW |