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

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

Issue 2069143002: Limit the number of accelerated canvases that can exist in a render process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix layout test Created 4 years, 6 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) 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 class ImageBufferClient; 66 class ImageBufferClient;
67 class IntPoint; 67 class IntPoint;
68 class IntRect; 68 class IntRect;
69 69
70 enum Multiply { 70 enum Multiply {
71 Premultiplied, 71 Premultiplied,
72 Unmultiplied 72 Unmultiplied
73 }; 73 };
74 74
75 class PLATFORM_EXPORT ImageBuffer { 75 class PLATFORM_EXPORT ImageBuffer {
76 WTF_MAKE_NONCOPYABLE(ImageBuffer); USING_FAST_MALLOC(ImageBuffer); 76 WTF_MAKE_NONCOPYABLE(ImageBuffer);
77 USING_FAST_MALLOC(ImageBuffer);
77 public: 78 public:
78 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu e, ImageInitializationMode = InitializeImagePixels); 79 static PassOwnPtr<ImageBuffer> create(const IntSize&, OpacityMode = NonOpaqu e, ImageInitializationMode = InitializeImagePixels);
79 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>); 80 static PassOwnPtr<ImageBuffer> create(PassOwnPtr<ImageBufferSurface>);
80 81
81 virtual ~ImageBuffer(); 82 virtual ~ImageBuffer();
82 83
83 void setClient(ImageBufferClient* client) { m_client = client; } 84 void setClient(ImageBufferClient* client) { m_client = client; }
84 85
85 const IntSize& size() const { return m_surface->size(); } 86 const IntSize& size() const { return m_surface->size(); }
86 bool isAccelerated() const { return m_surface->isAccelerated(); } 87 bool isAccelerated() const { return m_surface->isAccelerated(); }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 136
136 PassRefPtr<SkImage> newSkImageSnapshot(AccelerationHint, SnapshotReason) con st; 137 PassRefPtr<SkImage> newSkImageSnapshot(AccelerationHint, SnapshotReason) con st;
137 PassRefPtr<Image> newImageSnapshot(AccelerationHint = PreferNoAcceleration, SnapshotReason = SnapshotReasonUnknown) const; 138 PassRefPtr<Image> newImageSnapshot(AccelerationHint = PreferNoAcceleration, SnapshotReason = SnapshotReasonUnknown) const;
138 139
139 PassRefPtr<SkPicture> getPicture() { return m_surface->getPicture(); } 140 PassRefPtr<SkPicture> getPicture() { return m_surface->getPicture(); }
140 141
141 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode:: Mode); 142 void draw(GraphicsContext&, const FloatRect&, const FloatRect*, SkXfermode:: Mode);
142 143
143 void updateGPUMemoryUsage() const; 144 void updateGPUMemoryUsage() const;
144 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; } 145 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; }
146 static unsigned getGlobalAcceleratedImageBufferCount() { return s_globalAcce leratedImageBufferCount; }
145 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; } 147 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; }
146 148
147 protected: 149 protected:
148 ImageBuffer(PassOwnPtr<ImageBufferSurface>); 150 ImageBuffer(PassOwnPtr<ImageBufferSurface>);
149 151
150 private: 152 private:
151 enum SnapshotState { 153 enum SnapshotState {
152 InitialSnapshotState, 154 InitialSnapshotState,
153 DidAcquireSnapshot, 155 DidAcquireSnapshot,
154 DrawnToAfterSnapshot, 156 DrawnToAfterSnapshot,
155 }; 157 };
156 mutable SnapshotState m_snapshotState; 158 mutable SnapshotState m_snapshotState;
157 OwnPtr<ImageBufferSurface> m_surface; 159 OwnPtr<ImageBufferSurface> m_surface;
158 ImageBufferClient* m_client; 160 ImageBufferClient* m_client;
159 161
160 mutable intptr_t m_gpuMemoryUsage; 162 mutable intptr_t m_gpuMemoryUsage;
161 static intptr_t s_globalGPUMemoryUsage; 163 static intptr_t s_globalGPUMemoryUsage;
164 static unsigned s_globalAcceleratedImageBufferCount;
162 }; 165 };
163 166
164 struct ImageDataBuffer { 167 struct ImageDataBuffer {
165 STACK_ALLOCATED(); 168 STACK_ALLOCATED();
166 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat a), m_size(size) { } 169 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat a), m_size(size) { }
167 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali ty) const; 170 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali ty) const;
168 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali ty, Vector<unsigned char>* encodedImage) const; 171 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali ty, Vector<unsigned char>* encodedImage) const;
169 const unsigned char* pixels() const { return m_data; } 172 const unsigned char* pixels() const { return m_data; }
170 const IntSize& size() const { return m_size; } 173 const IntSize& size() const { return m_size; }
171 int height() const { return m_size.height(); } 174 int height() const { return m_size.height(); }
172 int width() const { return m_size.width(); } 175 int width() const { return m_size.width(); }
173 176
174 const unsigned char* m_data; 177 const unsigned char* m_data;
175 const IntSize m_size; 178 const IntSize m_size;
176 }; 179 };
177 180
178 } // namespace blink 181 } // namespace blink
179 182
180 #endif // ImageBuffer_h 183 #endif // ImageBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698