Chromium Code Reviews

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: adding missing histogram Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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...)
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 FallbackReasonCount,
84 };
64 private: 85 private:
65 friend class RecordingImageBufferSurfaceTest; // for unit testing 86 friend class RecordingImageBufferSurfaceTest; // for unit testing
66 void fallBackToRasterCanvas(); 87 void fallBackToRasterCanvas(FallbackReason);
67 bool initializeCurrentFrame(); 88 void initializeCurrentFrame();
68 bool finalizeFrameInternal(); 89 bool finalizeFrameInternal(FallbackReason*);
69 int approximateOpCount(); 90 int approximateOpCount();
70 91
71 OwnPtr<SkPictureRecorder> m_currentFrame; 92 OwnPtr<SkPictureRecorder> m_currentFrame;
72 RefPtr<SkPicture> m_previousFrame; 93 RefPtr<SkPicture> m_previousFrame;
73 OwnPtr<ImageBufferSurface> m_fallbackSurface; 94 OwnPtr<ImageBufferSurface> m_fallbackSurface;
74 ImageBuffer* m_imageBuffer; 95 ImageBuffer* m_imageBuffer;
75 int m_initialSaveCount; 96 int m_initialSaveCount;
76 int m_currentFramePixelCount; 97 int m_currentFramePixelCount;
77 int m_previousFramePixelCount; 98 int m_previousFramePixelCount;
78 bool m_frameWasCleared; 99 bool m_frameWasCleared;
79 bool m_didRecordDrawCommandsInCurrentFrame; 100 bool m_didRecordDrawCommandsInCurrentFrame;
80 bool m_currentFrameHasExpensiveOp; 101 bool m_currentFrameHasExpensiveOp;
81 bool m_previousFrameHasExpensiveOp; 102 bool m_previousFrameHasExpensiveOp;
82 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> m_fallbackFactory; 103 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> m_fallbackFactory;
83 }; 104 };
84 105
85 } // namespace blink 106 } // namespace blink
86 107
87 #endif 108 #endif
OLDNEW

Powered by Google App Engine