OLD | NEW |
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 void flush(); // process deferred draw commands immediately | 124 void flush(); // process deferred draw commands immediately |
125 void flushGpu(); // Like flush(), but flushes all the way down to the Gpu co
ntext if the surface is accelerated | 125 void flushGpu(); // Like flush(), but flushes all the way down to the Gpu co
ntext if the surface is accelerated |
126 | 126 |
127 void notifySurfaceInvalid(); | 127 void notifySurfaceInvalid(); |
128 | 128 |
129 PassRefPtr<SkImage> newSkImageSnapshot(AccelerationHint) const; | 129 PassRefPtr<SkImage> newSkImageSnapshot(AccelerationHint) const; |
130 PassRefPtr<Image> newImageSnapshot(AccelerationHint = PreferNoAcceleration)
const; | 130 PassRefPtr<Image> newImageSnapshot(AccelerationHint = PreferNoAcceleration)
const; |
131 | 131 |
132 void draw(GraphicsContext*, const FloatRect&, const FloatRect*, SkXfermode::
Mode); | 132 void draw(GraphicsContext*, const FloatRect&, const FloatRect*, SkXfermode::
Mode); |
133 | 133 |
| 134 void updateGPUMemoryUsage() const; |
| 135 static intptr_t getGlobalGPUMemoryUsage() { return s_globalGPUMemoryUsage; } |
| 136 intptr_t getGPUMemoryUsage() { return m_gpuMemoryUsage; } |
| 137 |
134 private: | 138 private: |
135 ImageBuffer(PassOwnPtr<ImageBufferSurface>); | 139 ImageBuffer(PassOwnPtr<ImageBufferSurface>); |
136 | 140 |
137 enum SnapshotState { | 141 enum SnapshotState { |
138 InitialSnapshotState, | 142 InitialSnapshotState, |
139 DidAcquireSnapshot, | 143 DidAcquireSnapshot, |
140 DrawnToAfterSnapshot, | 144 DrawnToAfterSnapshot, |
141 }; | 145 }; |
142 mutable SnapshotState m_snapshotState; | 146 mutable SnapshotState m_snapshotState; |
143 OwnPtr<ImageBufferSurface> m_surface; | 147 OwnPtr<ImageBufferSurface> m_surface; |
144 ImageBufferClient* m_client; | 148 ImageBufferClient* m_client; |
| 149 |
| 150 mutable intptr_t m_gpuMemoryUsage; |
| 151 static intptr_t s_globalGPUMemoryUsage; |
145 }; | 152 }; |
146 | 153 |
147 struct ImageDataBuffer { | 154 struct ImageDataBuffer { |
148 STACK_ALLOCATED(); | 155 STACK_ALLOCATED(); |
149 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat
a), m_size(size) { } | 156 ImageDataBuffer(const IntSize& size, const unsigned char* data) : m_data(dat
a), m_size(size) { } |
150 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali
ty) const; | 157 String PLATFORM_EXPORT toDataURL(const String& mimeType, const double& quali
ty) const; |
151 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali
ty, Vector<unsigned char>* encodedImage) const; | 158 bool PLATFORM_EXPORT encodeImage(const String& mimeType, const double& quali
ty, Vector<unsigned char>* encodedImage) const; |
152 const unsigned char* pixels() const { return m_data; } | 159 const unsigned char* pixels() const { return m_data; } |
153 int height() const { return m_size.height(); } | 160 int height() const { return m_size.height(); } |
154 int width() const { return m_size.width(); } | 161 int width() const { return m_size.width(); } |
155 | 162 |
156 const unsigned char* m_data; | 163 const unsigned char* m_data; |
157 const IntSize m_size; | 164 const IntSize m_size; |
158 }; | 165 }; |
159 | 166 |
160 } // namespace blink | 167 } // namespace blink |
161 | 168 |
162 #endif // ImageBuffer_h | 169 #endif // ImageBuffer_h |
OLD | NEW |