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