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

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

Issue 1520123002: Fix state restoration logic in canvas 2d wakeup from hibernation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/GraphicsTypes.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Premultiplied, 65 Premultiplied,
66 Unmultiplied 66 Unmultiplied
67 }; 67 };
68 68
69 class PLATFORM_EXPORT ImageBuffer { 69 class PLATFORM_EXPORT ImageBuffer {
70 WTF_MAKE_NONCOPYABLE(ImageBuffer); USING_FAST_MALLOC(ImageBuffer); 70 WTF_MAKE_NONCOPYABLE(ImageBuffer); USING_FAST_MALLOC(ImageBuffer);
71 public: 71 public:
72 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu e, ImageInitializationMode = InitializeImagePixels); 72 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu e, ImageInitializationMode = InitializeImagePixels);
73 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>); 73 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>);
74 74
75 ~ImageBuffer(); 75 virtual ~ImageBuffer();
76 76
77 void setClient(ImageBufferClient* client) { m_client = client; } 77 void setClient(ImageBufferClient* client) { m_client = client; }
78 78
79 const IntSize& size() const { return m_surface->size(); } 79 const IntSize& size() const { return m_surface->size(); }
80 bool isAccelerated() const { return m_surface->isAccelerated(); } 80 bool isAccelerated() const { return m_surface->isAccelerated(); }
81 bool isRecording() const { return m_surface->isRecording(); } 81 bool isRecording() const { return m_surface->isRecording(); }
82 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); } 82 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); }
83 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); } 83 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); }
84 void prepareSurfaceForPaintingIfNeeded() { m_surface->prepareSurfaceForPaint ingIfNeeded(); } 84 void prepareSurfaceForPaintingIfNeeded() { m_surface->prepareSurfaceForPaint ingIfNeeded(); }
85 bool isSurfaceValid() const; 85 bool isSurfaceValid() const;
86 bool restoreSurface() const; 86 bool restoreSurface() const;
87 void didDraw(const FloatRect&) const; 87 void didDraw(const FloatRect&) const;
88 bool wasDrawnToAfterSnapshot() const { return m_snapshotState == DrawnToAfte rSnapshot; } 88 bool wasDrawnToAfterSnapshot() const { return m_snapshotState == DrawnToAfte rSnapshot; }
89 89
90 void setFilterQuality(SkFilterQuality filterQuality) { m_surface->setFilterQ uality(filterQuality); } 90 void setFilterQuality(SkFilterQuality filterQuality) { m_surface->setFilterQ uality(filterQuality); }
91 void setIsHidden(bool hidden) { m_surface->setIsHidden(hidden); } 91 void setIsHidden(bool hidden) { m_surface->setIsHidden(hidden); }
92 92
93 // Called by subclasses of ImageBufferSurface to install a new canvas object 93 // Called by subclasses of ImageBufferSurface to install a new canvas object .
94 void resetCanvas(SkCanvas*) const; 94 // Virtual for mocking
95 virtual void resetCanvas(SkCanvas*) const;
95 96
96 SkCanvas* canvas() const; 97 SkCanvas* canvas() const;
97 void disableDeferral() const; 98 void disableDeferral() const;
98 99
99 // Called at the end of a task that rendered a whole frame 100 // Called at the end of a task that rendered a whole frame
100 void finalizeFrame(const FloatRect &dirtyRect); 101 void finalizeFrame(const FloatRect &dirtyRect);
101 void didFinalizeFrame(); 102 void didFinalizeFrame();
102 103
103 bool isDirty(); 104 bool isDirty();
104 105
(...skipping 23 matching lines...) Expand all
128 129
129 PassRefPtr<SkImage> newSkImageSnapshot(AccelerationHint) const; 130 PassRefPtr<SkImage> newSkImageSnapshot(AccelerationHint) const;
130 PassRefPtr<Image> newImageSnapshot(AccelerationHint = PreferNoAcceleration) const; 131 PassRefPtr<Image> newImageSnapshot(AccelerationHint = PreferNoAcceleration) const;
131 132
132 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode:: Mode); 133 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode:: Mode);
133 134
134 void updateGPUMemoryUsage() const; 135 void updateGPUMemoryUsage() const;
135 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; } 136 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; }
136 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; } 137 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; }
137 138
138 private: 139 protected:
139 ImageBuffer(PassOwnPtr<ImageBufferSurface>); 140 ImageBuffer(PassOwnPtr<ImageBufferSurface>);
140 141
142 private:
141 enum SnapshotState { 143 enum SnapshotState {
142 InitialSnapshotState, 144 InitialSnapshotState,
143 DidAcquireSnapshot, 145 DidAcquireSnapshot,
144 DrawnToAfterSnapshot, 146 DrawnToAfterSnapshot,
145 }; 147 };
146 mutable SnapshotState m_snapshotState; 148 mutable SnapshotState m_snapshotState;
147 OwnPtr<ImageBufferSurface> m_surface; 149 OwnPtr<ImageBufferSurface> m_surface;
148 ImageBufferClient* m_client; 150 ImageBufferClient* m_client;
149 151
150 mutable intptr_t m_gpuMemoryUsage; 152 mutable intptr_t m_gpuMemoryUsage;
151 static intptr_t s_globalGPUMemoryUsage; 153 static intptr_t s_globalGPUMemoryUsage;
152 }; 154 };
153 155
154 struct ImageDataBuffer { 156 struct ImageDataBuffer {
155 STACK_ALLOCATED(); 157 STACK_ALLOCATED();
156 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat a), m_size(size) { } 158 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat a), m_size(size) { }
157 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali ty) const; 159 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali ty) const;
158 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali ty, Vector<unsigned char>* encodedImage) const; 160 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali ty, Vector<unsigned char>* encodedImage) const;
159 const unsigned char* pixels() const { return m_data; } 161 const unsigned char* pixels() const { return m_data; }
160 int height() const { return m_size.height(); } 162 int height() const { return m_size.height(); }
161 int width() const { return m_size.width(); } 163 int width() const { return m_size.width(); }
162 164
163 const unsigned char* m_data; 165 const unsigned char* m_data;
164 const IntSize m_size; 166 const IntSize m_size;
165 }; 167 };
166 168
167 } // namespace blink 169 } // namespace blink
168 170
169 #endif // ImageBuffer_h 171 #endif // ImageBuffer_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/GraphicsTypes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698