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

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

Issue 1609343004: Add display list fallback reason histograms for 2D canvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git cl web Created 4 years, 10 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef RecordingImageBufferSurface_h 5 #ifndef RecordingImageBufferSurface_h
6 #define RecordingImageBufferSurface_h 6 #define RecordingImageBufferSurface_h
7 7
8 #include "platform/graphics/GraphicsContext.h" 8 #include "platform/graphics/GraphicsContext.h"
9 #include "platform/graphics/ImageBufferSurface.h" 9 #include "platform/graphics/ImageBufferSurface.h"
10 #include "public/platform/WebThread.h" 10 #include "public/platform/WebThread.h"
(...skipping 22 matching lines...) Expand all
33 }; 33 };
34 34
35 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface { 35 class PLATFORM_EXPORT RecordingImageBufferSurface : public ImageBufferSurface {
36 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); USING_FAST_MALLOC(Recordi ngImageBufferSurface); 36 WTF_MAKE_NONCOPYABLE(RecordingImageBufferSurface); USING_FAST_MALLOC(Recordi ngImageBufferSurface);
37 public: 37 public:
38 RecordingImageBufferSurface(const IntSize&, PassOwnPtr<RecordingImageBufferF allbackSurfaceFactory> fallbackFactory, OpacityMode = NonOpaque); 38 RecordingImageBufferSurface(const IntSize&, PassOwnPtr<RecordingImageBufferF allbackSurfaceFactory> fallbackFactory, OpacityMode = NonOpaque);
39 ~RecordingImageBufferSurface() override; 39 ~RecordingImageBufferSurface() override;
40 40
41 // Implementation of ImageBufferSurface interfaces 41 // Implementation of ImageBufferSurface interfaces
42 SkCanvas* canvas() override; 42 SkCanvas* canvas() override;
43 void disableDeferral() override; 43 void disableDeferral(DisableDeferralReason) override;
44 PassRefPtr<SkPicture> getPicture() override; 44 PassRefPtr<SkPicture> getPicture() override;
45 void flush() override; 45 void flush(FlushReason) override;
46 void didDraw(const FloatRect&) override; 46 void didDraw(const FloatRect&) override;
47 bool isValid() const override { return true; } 47 bool isValid() const override { return true; }
48 bool isRecording() const override { return !m_fallbackSurface; } 48 bool isRecording() const override { return !m_fallbackSurface; }
49 bool writePixels(const SkImageInfo& origInfo, const void* pixels, size_t row Bytes, int x, int y) override; 49 bool writePixels(const SkImageInfo& origInfo, const void* pixels, size_t row Bytes, int x, int y) override;
50 void willOverwriteCanvas() override; 50 void willOverwriteCanvas() override;
51 virtual void finalizeFrame(const FloatRect&); 51 virtual void finalizeFrame(const FloatRect&);
52 void setImageBuffer(ImageBuffer*) override; 52 void setImageBuffer(ImageBuffer*) override;
53 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint) override; 53 PassRefPtr<SkImage> newImageSnapshot(AccelerationHint, SnapshotReason) overr ide;
54 void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcR ect, SkXfermode::Mode) override; 54 void draw(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcR ect, SkXfermode::Mode) override;
55 bool isExpensiveToPaint() override; 55 bool isExpensiveToPaint() override;
56 void setHasExpensiveOp() override { m_currentFrameHasExpensiveOp = true; } 56 void setHasExpensiveOp() override { m_currentFrameHasExpensiveOp = true; }
57 57
58 // Passthroughs to fallback surface 58 // Passthroughs to fallback surface
59 bool restore() override; 59 bool restore() override;
60 WebLayer* layer() const override; 60 WebLayer* layer() const override;
61 bool isAccelerated() const override; 61 bool isAccelerated() const override;
62 void setIsHidden(bool) override; 62 void setIsHidden(bool) override;
63 63
64 enum FallbackReason {
65 FallbackReasonUnknown = 0, // This value should never appear in producti on histograms
66 FallbackReasonCanvasNotClearedBetweenFrames = 1,
67 FallbackReasonRunawayStateStack = 2,
68 FallbackReasonWritePixels = 3,
69 FallbackReasonFlushInitialClear = 4,
70 FallbackReasonFlushForDrawImageOfWebGL = 5,
71 FallbackReasonSnapshotForGetImageData = 6,
72 FallbackReasonSnapshotForCopyToWebGLTexture = 7,
73 FallbackReasonSnapshotForPaint = 8,
74 FallbackReasonSnapshotForToDataURL = 9,
75 FallbackReasonSnapshotForToBlob = 10,
76 FallbackReasonSnapshotForCanvasListenerCapture = 11,
77 FallbackReasonSnapshotForDrawImage = 12,
78 FallbackReasonSnapshotForCreatePattern = 13,
79 FallbackReasonExpensiveOverdrawHeuristic = 14,
80 FallbackReasonTextureBackedPattern = 15,
81 FallbackReasonDrawImageOfVideo = 16,
82 FallbackReasonDrawImageOfAnimated2dCanvas = 17,
83 FallbackReasonSubPixelTextAntiAliasingSupport = 18,
84 FallbackReasonCount,
85 };
64 private: 86 private:
65 friend class RecordingImageBufferSurfaceTest; // for unit testing 87 friend class RecordingImageBufferSurfaceTest; // for unit testing
66 void fallBackToRasterCanvas(); 88 void fallBackToRasterCanvas(FallbackReason);
67 bool initializeCurrentFrame(); 89 void initializeCurrentFrame();
68 bool finalizeFrameInternal(); 90 bool finalizeFrameInternal(FallbackReason*);
69 int approximateOpCount(); 91 int approximateOpCount();
70 92
71 OwnPtr<SkPictureRecorder> m_currentFrame; 93 OwnPtr<SkPictureRecorder> m_currentFrame;
72 RefPtr<SkPicture> m_previousFrame; 94 RefPtr<SkPicture> m_previousFrame;
73 OwnPtr<ImageBufferSurface> m_fallbackSurface; 95 OwnPtr<ImageBufferSurface> m_fallbackSurface;
74 ImageBuffer* m_imageBuffer; 96 ImageBuffer* m_imageBuffer;
75 int m_initialSaveCount; 97 int m_initialSaveCount;
76 int m_currentFramePixelCount; 98 int m_currentFramePixelCount;
77 int m_previousFramePixelCount; 99 int m_previousFramePixelCount;
78 bool m_frameWasCleared; 100 bool m_frameWasCleared;
79 bool m_didRecordDrawCommandsInCurrentFrame; 101 bool m_didRecordDrawCommandsInCurrentFrame;
80 bool m_currentFrameHasExpensiveOp; 102 bool m_currentFrameHasExpensiveOp;
81 bool m_previousFrameHasExpensiveOp; 103 bool m_previousFrameHasExpensiveOp;
82 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> m_fallbackFactory; 104 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> m_fallbackFactory;
83 }; 105 };
84 106
85 } // namespace blink 107 } // namespace blink
86 108
87 #endif 109 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698