| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CC_RESOURCE_PROVIDER_H_ | 5 #ifndef CC_RESOURCE_PROVIDER_H_ |
| 6 #define CC_RESOURCE_PROVIDER_H_ | 6 #define CC_RESOURCE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <deque> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 8 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" |
| 9 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
| 10 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 12 #include "cc/cc_export.h" | 17 #include "cc/cc_export.h" |
| 13 #include "cc/output_surface.h" | 18 #include "cc/output_surface.h" |
| 14 #include "cc/texture_copier.h" | 19 #include "cc/texture_copier.h" |
| 15 #include "cc/transferable_resource.h" | 20 #include "cc/transferable_resource.h" |
| 16 #include "third_party/khronos/GLES2/gl2.h" | 21 #include "third_party/khronos/GLES2/gl2.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" | 23 #include "third_party/skia/include/core/SkCanvas.h" |
| 19 #include "ui/gfx/size.h" | 24 #include "ui/gfx/size.h" |
| 20 #include <deque> | |
| 21 #include <vector> | |
| 22 | 25 |
| 23 namespace WebKit { | 26 namespace WebKit { |
| 24 class WebGraphicsContext3D; | 27 class WebGraphicsContext3D; |
| 25 } | 28 } |
| 26 | 29 |
| 27 namespace gfx { | 30 namespace gfx { |
| 28 class Rect; | 31 class Rect; |
| 29 class Vector2d; | 32 class Vector2d; |
| 30 } | 33 } |
| 31 | 34 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // Creates a resource which is tagged as being managed for GPU memory accoun
ting purposes. | 78 // Creates a resource which is tagged as being managed for GPU memory accoun
ting purposes. |
| 76 ResourceId createManagedResource(const gfx::Size&, GLenum format, TextureUsa
geHint); | 79 ResourceId createManagedResource(const gfx::Size&, GLenum format, TextureUsa
geHint); |
| 77 | 80 |
| 78 // You can also explicitly create a specific resource type. | 81 // You can also explicitly create a specific resource type. |
| 79 ResourceId createGLTexture(const gfx::Size&, GLenum format, GLenum texturePo
ol, TextureUsageHint); | 82 ResourceId createGLTexture(const gfx::Size&, GLenum format, GLenum texturePo
ol, TextureUsageHint); |
| 80 | 83 |
| 81 ResourceId createBitmap(const gfx::Size&); | 84 ResourceId createBitmap(const gfx::Size&); |
| 82 // Wraps an external texture into a GL resource. | 85 // Wraps an external texture into a GL resource. |
| 83 ResourceId createResourceFromExternalTexture(unsigned textureId); | 86 ResourceId createResourceFromExternalTexture(unsigned textureId); |
| 84 | 87 |
| 88 // Wraps an external texture mailbox into a GL resource. |
| 89 ResourceId createResourceFromTextureMailbox(const std::string& mailboxName,
const base::Callback<void(unsigned)>& releaseCallback); |
| 90 |
| 85 void deleteResource(ResourceId); | 91 void deleteResource(ResourceId); |
| 86 | 92 |
| 87 // Update pixels from image, copying sourceRect (in image) into destRect (in
the resource). | 93 // Update pixels from image, copying sourceRect (in image) into destRect (in
the resource). |
| 88 void setPixels(ResourceId, const uint8_t* image, const gfx::Rect& imageRect,
const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset); | 94 void setPixels(ResourceId, const uint8_t* image, const gfx::Rect& imageRect,
const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset); |
| 89 | 95 |
| 90 // Check upload status. | 96 // Check upload status. |
| 91 size_t numBlockingUploads(); | 97 size_t numBlockingUploads(); |
| 92 void markPendingUploadsAsNonBlocking(); | 98 void markPendingUploadsAsNonBlocking(); |
| 93 double estimatedUploadsPerSecond(); | 99 double estimatedUploadsPerSecond(); |
| 94 void flushUploads(); | 100 void flushUploads(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // Update pixels from acquired pixel buffer. | 232 // Update pixels from acquired pixel buffer. |
| 227 void setPixelsFromBuffer(ResourceId id); | 233 void setPixelsFromBuffer(ResourceId id); |
| 228 | 234 |
| 229 // Asynchronously update pixels from acquired pixel buffer. | 235 // Asynchronously update pixels from acquired pixel buffer. |
| 230 void beginSetPixels(ResourceId id); | 236 void beginSetPixels(ResourceId id); |
| 231 bool didSetPixelsComplete(ResourceId id); | 237 bool didSetPixelsComplete(ResourceId id); |
| 232 | 238 |
| 233 private: | 239 private: |
| 234 struct Resource { | 240 struct Resource { |
| 235 Resource(); | 241 Resource(); |
| 242 ~Resource(); |
| 236 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); | 243 Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenu
m filter); |
| 237 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); | 244 Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum f
ilter); |
| 238 | 245 |
| 239 unsigned glId; | 246 unsigned glId; |
| 240 // Pixel buffer used for set pixels without unnecessary copying. | 247 // Pixel buffer used for set pixels without unnecessary copying. |
| 241 unsigned glPixelBufferId; | 248 unsigned glPixelBufferId; |
| 242 // Query used to determine when asynchronous set pixels complete. | 249 // Query used to determine when asynchronous set pixels complete. |
| 243 unsigned glUploadQueryId; | 250 unsigned glUploadQueryId; |
| 244 Mailbox mailbox; | 251 Mailbox mailbox; |
| 252 base::Callback<void(unsigned)> mailboxReleaseCallback; |
| 245 uint8_t* pixels; | 253 uint8_t* pixels; |
| 246 uint8_t* pixelBuffer; | 254 uint8_t* pixelBuffer; |
| 247 int lockForReadCount; | 255 int lockForReadCount; |
| 248 bool lockedForWrite; | 256 bool lockedForWrite; |
| 249 bool external; | 257 bool external; |
| 250 bool exported; | 258 bool exported; |
| 251 bool markedForDeletion; | 259 bool markedForDeletion; |
| 252 bool pendingSetPixels; | 260 bool pendingSetPixels; |
| 253 gfx::Size size; | 261 gfx::Size size; |
| 254 GLenum format; | 262 GLenum format; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 GLenum m_bestTextureFormat; | 302 GLenum m_bestTextureFormat; |
| 295 | 303 |
| 296 base::ThreadChecker m_threadChecker; | 304 base::ThreadChecker m_threadChecker; |
| 297 | 305 |
| 298 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); | 306 DISALLOW_COPY_AND_ASSIGN(ResourceProvider); |
| 299 }; | 307 }; |
| 300 | 308 |
| 301 } | 309 } |
| 302 | 310 |
| 303 #endif // CC_RESOURCE_PROVIDER_H_ | 311 #endif // CC_RESOURCE_PROVIDER_H_ |
| OLD | NEW |