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

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

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

Powered by Google App Engine
This is Rietveld 408576698