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 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "CCResourceProvider.h" | 7 #include "CCResourceProvider.h" |
8 #ifdef LOG | 8 #ifdef LOG |
9 #undef LOG | 9 #undef LOG |
10 #endif | 10 #endif |
11 | 11 |
12 #include <limits.h> | 12 #include <limits.h> |
13 | 13 |
14 #include "base/debug/alias.h" | 14 #include "base/debug/alias.h" |
15 #include "base/hash_tables.h" | 15 #include "base/hash_tables.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/string_split.h" | 17 #include "base/string_split.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 19 #include "third_party/khronos/GLES2/gl2.h" |
| 20 #include "third_party/khronos/GLES2/gl2ext.h" |
19 #include "CCProxy.h" | 21 #include "CCProxy.h" |
20 #include "CCRendererGL.h" // For the GLC() macro. | 22 #include "CCRendererGL.h" // For the GLC() macro. |
21 #include "Extensions3DChromium.h" | |
22 #include "IntRect.h" | 23 #include "IntRect.h" |
23 #include "LayerTextureSubImage.h" | 24 #include "LayerTextureSubImage.h" |
24 #include "ThrottledTextureUploader.h" | 25 #include "ThrottledTextureUploader.h" |
25 #include "UnthrottledTextureUploader.h" | 26 #include "UnthrottledTextureUploader.h" |
26 #include <public/WebGraphicsContext3D.h> | 27 #include <public/WebGraphicsContext3D.h> |
27 | 28 |
28 using WebKit::WebGraphicsContext3D; | 29 using WebKit::WebGraphicsContext3D; |
29 | 30 |
30 namespace cc { | 31 namespace cc { |
31 | 32 |
32 static GC3Denum textureToStorageFormat(GC3Denum textureFormat) | 33 static GLenum textureToStorageFormat(GLenum textureFormat) |
33 { | 34 { |
34 GC3Denum storageFormat = Extensions3D::RGBA8_OES; | 35 GLenum storageFormat = GL_RGBA8_OES; |
35 switch (textureFormat) { | 36 switch (textureFormat) { |
36 case GraphicsContext3D::RGBA: | 37 case GL_RGBA: |
37 break; | 38 break; |
38 case Extensions3D::BGRA_EXT: | 39 case GL_BGRA_EXT: |
39 storageFormat = Extensions3DChromium::BGRA8_EXT; | 40 storageFormat = GL_BGRA8_EXT; |
40 break; | 41 break; |
41 default: | 42 default: |
42 ASSERT_NOT_REACHED(); | 43 ASSERT_NOT_REACHED(); |
43 break; | 44 break; |
44 } | 45 } |
45 | 46 |
46 return storageFormat; | 47 return storageFormat; |
47 } | 48 } |
48 | 49 |
49 static bool isTextureFormatSupportedForStorage(GC3Denum format) | 50 static bool isTextureFormatSupportedForStorage(GLenum format) |
50 { | 51 { |
51 return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EX
T); | 52 return (format == GL_RGBA || format == GL_BGRA_EXT); |
52 } | 53 } |
53 | 54 |
54 CCResourceProvider::TransferableResourceList::TransferableResourceList() | 55 CCResourceProvider::TransferableResourceList::TransferableResourceList() |
55 { | 56 { |
56 } | 57 } |
57 | 58 |
58 CCResourceProvider::TransferableResourceList::~TransferableResourceList() | 59 CCResourceProvider::TransferableResourceList::~TransferableResourceList() |
59 { | 60 { |
60 } | 61 } |
61 | 62 |
62 CCResourceProvider::Resource::Resource() | 63 CCResourceProvider::Resource::Resource() |
63 : glId(0) | 64 : glId(0) |
64 , pixels(0) | 65 , pixels(0) |
65 , pool(0) | 66 , pool(0) |
66 , lockForReadCount(0) | 67 , lockForReadCount(0) |
67 , lockedForWrite(false) | 68 , lockedForWrite(false) |
68 , external(false) | 69 , external(false) |
69 , exported(false) | 70 , exported(false) |
70 , markedForDeletion(false) | 71 , markedForDeletion(false) |
71 , size() | 72 , size() |
72 , format(0) | 73 , format(0) |
73 , type(static_cast<ResourceType>(0)) | 74 , type(static_cast<ResourceType>(0)) |
74 { | 75 { |
75 } | 76 } |
76 | 77 |
77 CCResourceProvider::Resource::Resource(unsigned textureId, int pool, const IntSi
ze& size, GC3Denum format) | 78 CCResourceProvider::Resource::Resource(unsigned textureId, int pool, const IntSi
ze& size, GLenum format) |
78 : glId(textureId) | 79 : glId(textureId) |
79 , pixels(0) | 80 , pixels(0) |
80 , pool(pool) | 81 , pool(pool) |
81 , lockForReadCount(0) | 82 , lockForReadCount(0) |
82 , lockedForWrite(false) | 83 , lockedForWrite(false) |
83 , external(false) | 84 , external(false) |
84 , exported(false) | 85 , exported(false) |
85 , markedForDeletion(false) | 86 , markedForDeletion(false) |
86 , size(size) | 87 , size(size) |
87 , format(format) | 88 , format(format) |
88 , type(GLTexture) | 89 , type(GLTexture) |
89 { | 90 { |
90 } | 91 } |
91 | 92 |
92 CCResourceProvider::Resource::Resource(uint8_t* pixels, int pool, const IntSize&
size, GC3Denum format) | 93 CCResourceProvider::Resource::Resource(uint8_t* pixels, int pool, const IntSize&
size, GLenum format) |
93 : glId(0) | 94 : glId(0) |
94 , pixels(pixels) | 95 , pixels(pixels) |
95 , pool(pool) | 96 , pool(pool) |
96 , lockForReadCount(0) | 97 , lockForReadCount(0) |
97 , lockedForWrite(false) | 98 , lockedForWrite(false) |
98 , external(false) | 99 , external(false) |
99 , exported(false) | 100 , exported(false) |
100 , markedForDeletion(false) | 101 , markedForDeletion(false) |
101 , size(size) | 102 , size(size) |
102 , format(format) | 103 , format(format) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ResourceMap::iterator it = m_resources.find(id); | 142 ResourceMap::iterator it = m_resources.find(id); |
142 CHECK(it != m_resources.end()); | 143 CHECK(it != m_resources.end()); |
143 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | 144 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
144 Resource* resource = &it->value; | 145 Resource* resource = &it->value; |
145 #else | 146 #else |
146 Resource* resource = &it->second; | 147 Resource* resource = &it->second; |
147 #endif | 148 #endif |
148 return !!resource->lockForReadCount || resource->exported; | 149 return !!resource->lockForReadCount || resource->exported; |
149 } | 150 } |
150 | 151 |
151 CCResourceProvider::ResourceId CCResourceProvider::createResource(int pool, cons
t IntSize& size, GC3Denum format, TextureUsageHint hint) | 152 CCResourceProvider::ResourceId CCResourceProvider::createResource(int pool, cons
t IntSize& size, GLenum format, TextureUsageHint hint) |
152 { | 153 { |
153 switch (m_defaultResourceType) { | 154 switch (m_defaultResourceType) { |
154 case GLTexture: | 155 case GLTexture: |
155 return createGLTexture(pool, size, format, hint); | 156 return createGLTexture(pool, size, format, hint); |
156 case Bitmap: | 157 case Bitmap: |
157 ASSERT(format == GraphicsContext3D::RGBA); | 158 ASSERT(format == GL_RGBA); |
158 return createBitmap(pool, size); | 159 return createBitmap(pool, size); |
159 } | 160 } |
160 | 161 |
161 CRASH(); | 162 CRASH(); |
162 return 0; | 163 return 0; |
163 } | 164 } |
164 | 165 |
165 CCResourceProvider::ResourceId CCResourceProvider::createGLTexture(int pool, con
st IntSize& size, GC3Denum format, TextureUsageHint hint) | 166 CCResourceProvider::ResourceId CCResourceProvider::createGLTexture(int pool, con
st IntSize& size, GLenum format, TextureUsageHint hint) |
166 { | 167 { |
167 ASSERT(CCProxy::isImplThread()); | 168 ASSERT(CCProxy::isImplThread()); |
168 unsigned textureId = 0; | 169 unsigned textureId = 0; |
169 WebGraphicsContext3D* context3d = m_context->context3D(); | 170 WebGraphicsContext3D* context3d = m_context->context3D(); |
170 ASSERT(context3d); | 171 ASSERT(context3d); |
171 GLC(context3d, textureId = context3d->createTexture()); | 172 GLC(context3d, textureId = context3d->createTexture()); |
172 GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, texture
Id)); | 173 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
173 GLC(context3d, context3d->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph
icsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR)); | 174 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER
, GL_LINEAR)); |
174 GLC(context3d, context3d->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph
icsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR)); | 175 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER
, GL_LINEAR)); |
175 GLC(context3d, context3d->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph
icsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE)); | 176 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL
_CLAMP_TO_EDGE)); |
176 GLC(context3d, context3d->texParameteri(GraphicsContext3D::TEXTURE_2D, Graph
icsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE)); | 177 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL
_CLAMP_TO_EDGE)); |
177 | 178 |
178 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) | 179 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) |
179 GLC(context3d, context3d->texParameteri(GraphicsContext3D::TEXTURE_2D, E
xtensions3DChromium::GL_TEXTURE_USAGE_ANGLE, Extensions3DChromium::GL_FRAMEBUFFE
R_ATTACHMENT_ANGLE)); | 180 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_
ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); |
180 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { | 181 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { |
181 GC3Denum storageFormat = textureToStorageFormat(format); | 182 GLenum storageFormat = textureToStorageFormat(format); |
182 GLC(context3d, context3d->texStorage2DEXT(GraphicsContext3D::TEXTURE_2D,
1, storageFormat, size.width(), size.height())); | 183 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma
t, size.width(), size.height())); |
183 } else | 184 } else |
184 GLC(context3d, context3d->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, f
ormat, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE,
0)); | 185 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt
h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); |
185 ResourceId id = m_nextId++; | 186 ResourceId id = m_nextId++; |
186 Resource resource(textureId, pool, size, format); | 187 Resource resource(textureId, pool, size, format); |
187 m_resources.add(id, resource); | 188 m_resources.add(id, resource); |
188 return id; | 189 return id; |
189 } | 190 } |
190 | 191 |
191 CCResourceProvider::ResourceId CCResourceProvider::createBitmap(int pool, const
IntSize& size) | 192 CCResourceProvider::ResourceId CCResourceProvider::createBitmap(int pool, const
IntSize& size) |
192 { | 193 { |
193 ASSERT(CCProxy::isImplThread()); | 194 ASSERT(CCProxy::isImplThread()); |
194 | 195 |
195 uint8_t* pixels = new uint8_t[size.width() * size.height() * 4]; | 196 uint8_t* pixels = new uint8_t[size.width() * size.height() * 4]; |
196 | 197 |
197 ResourceId id = m_nextId++; | 198 ResourceId id = m_nextId++; |
198 Resource resource(pixels, pool, size, GraphicsContext3D::RGBA); | 199 Resource resource(pixels, pool, size, GL_RGBA); |
199 m_resources.add(id, resource); | 200 m_resources.add(id, resource); |
200 return id; | 201 return id; |
201 } | 202 } |
202 | 203 |
203 CCResourceProvider::ResourceId CCResourceProvider::createResourceFromExternalTex
ture(unsigned textureId) | 204 CCResourceProvider::ResourceId CCResourceProvider::createResourceFromExternalTex
ture(unsigned textureId) |
204 { | 205 { |
205 ASSERT(CCProxy::isImplThread()); | 206 ASSERT(CCProxy::isImplThread()); |
206 ASSERT(m_context->context3D()); | 207 ASSERT(m_context->context3D()); |
207 ResourceId id = m_nextId++; | 208 ResourceId id = m_nextId++; |
208 Resource resource(textureId, 0, IntSize(), 0); | 209 Resource resource(textureId, 0, IntSize(), 0); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 #endif | 292 #endif |
292 ASSERT(!resource->lockedForWrite); | 293 ASSERT(!resource->lockedForWrite); |
293 ASSERT(!resource->lockForReadCount); | 294 ASSERT(!resource->lockForReadCount); |
294 ASSERT(!resource->external); | 295 ASSERT(!resource->external); |
295 ASSERT(!resource->exported); | 296 ASSERT(!resource->exported); |
296 | 297 |
297 if (resource->glId) { | 298 if (resource->glId) { |
298 WebGraphicsContext3D* context3d = m_context->context3D(); | 299 WebGraphicsContext3D* context3d = m_context->context3D(); |
299 ASSERT(context3d); | 300 ASSERT(context3d); |
300 ASSERT(m_texSubImage.get()); | 301 ASSERT(m_texSubImage.get()); |
301 context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, resource->glId); | 302 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); |
302 m_texSubImage->upload(image, imageRect, sourceRect, destOffset, resource
->format, context3d); | 303 m_texSubImage->upload(image, imageRect, sourceRect, destOffset, resource
->format, context3d); |
303 } | 304 } |
304 | 305 |
305 if (resource->pixels) { | 306 if (resource->pixels) { |
306 SkBitmap srcFull; | 307 SkBitmap srcFull; |
307 srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageR
ect.height()); | 308 srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageR
ect.height()); |
308 srcFull.setPixels(const_cast<uint8_t*>(image)); | 309 srcFull.setPixels(const_cast<uint8_t*>(image)); |
309 SkBitmap srcSubset; | 310 SkBitmap srcSubset; |
310 SkIRect skSourceRect = SkIRect::MakeXYWH(sourceRect.x(), sourceRect.y(),
sourceRect.width(), sourceRect.height()); | 311 SkIRect skSourceRect = SkIRect::MakeXYWH(sourceRect.x(), sourceRect.y(),
sourceRect.width(), sourceRect.height()); |
311 skSourceRect.offset(-imageRect.x(), -imageRect.y()); | 312 skSourceRect.offset(-imageRect.x(), -imageRect.y()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 } | 425 } |
425 | 426 |
426 CCResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() | 427 CCResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() |
427 { | 428 { |
428 m_resourceProvider->unlockForWrite(m_resourceId); | 429 m_resourceProvider->unlockForWrite(m_resourceId); |
429 } | 430 } |
430 | 431 |
431 void CCResourceProvider::populateSkBitmapWithResource(SkBitmap* skBitmap, const
Resource* resource) | 432 void CCResourceProvider::populateSkBitmapWithResource(SkBitmap* skBitmap, const
Resource* resource) |
432 { | 433 { |
433 ASSERT(resource->pixels); | 434 ASSERT(resource->pixels); |
434 ASSERT(resource->format == GraphicsContext3D::RGBA); | 435 ASSERT(resource->format == GL_RGBA); |
435 skBitmap->setConfig(SkBitmap::kARGB_8888_Config, resource->size.width(), res
ource->size.height()); | 436 skBitmap->setConfig(SkBitmap::kARGB_8888_Config, resource->size.width(), res
ource->size.height()); |
436 skBitmap->setPixels(resource->pixels); | 437 skBitmap->setPixels(resource->pixels); |
437 } | 438 } |
438 | 439 |
439 CCResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware(CCResourcePro
vider* resourceProvider, CCResourceProvider::ResourceId resourceId) | 440 CCResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware(CCResourcePro
vider* resourceProvider, CCResourceProvider::ResourceId resourceId) |
440 : m_resourceProvider(resourceProvider) | 441 : m_resourceProvider(resourceProvider) |
441 , m_resourceId(resourceId) | 442 , m_resourceId(resourceId) |
442 { | 443 { |
443 CCResourceProvider::populateSkBitmapWithResource(&m_skBitmap, resourceProvid
er->lockForRead(resourceId)); | 444 CCResourceProvider::populateSkBitmapWithResource(&m_skBitmap, resourceProvid
er->lockForRead(resourceId)); |
444 } | 445 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 ASSERT(CCProxy::isImplThread()); | 479 ASSERT(CCProxy::isImplThread()); |
479 WebGraphicsContext3D* context3d = m_context->context3D(); | 480 WebGraphicsContext3D* context3d = m_context->context3D(); |
480 if (!context3d) { | 481 if (!context3d) { |
481 m_maxTextureSize = INT_MAX / 2; | 482 m_maxTextureSize = INT_MAX / 2; |
482 m_textureUploader = UnthrottledTextureUploader::create(); | 483 m_textureUploader = UnthrottledTextureUploader::create(); |
483 return true; | 484 return true; |
484 } | 485 } |
485 if (!context3d->makeContextCurrent()) | 486 if (!context3d->makeContextCurrent()) |
486 return false; | 487 return false; |
487 | 488 |
488 std::string extensionsString = UTF16ToASCII(context3d->getString(GraphicsCon
text3D::EXTENSIONS)); | 489 std::string extensionsString = UTF16ToASCII(context3d->getString(GL_EXTENSIO
NS)); |
489 std::vector<std::string> extensions; | 490 std::vector<std::string> extensions; |
490 base::SplitString(extensionsString, ' ', &extensions); | 491 base::SplitString(extensionsString, ' ', &extensions); |
491 bool useMapSub = false; | 492 bool useMapSub = false; |
492 bool useBindUniform = false; | 493 bool useBindUniform = false; |
493 for (size_t i = 0; i < extensions.size(); ++i) { | 494 for (size_t i = 0; i < extensions.size(); ++i) { |
494 if (extensions[i] == "GL_EXT_texture_storage") | 495 if (extensions[i] == "GL_EXT_texture_storage") |
495 m_useTextureStorageExt = true; | 496 m_useTextureStorageExt = true; |
496 else if (extensions[i] == "GL_ANGLE_texture_usage") | 497 else if (extensions[i] == "GL_ANGLE_texture_usage") |
497 m_useTextureUsageHint = true; | 498 m_useTextureUsageHint = true; |
498 else if (extensions[i] == "GL_CHROMIUM_map_sub") | 499 else if (extensions[i] == "GL_CHROMIUM_map_sub") |
499 useMapSub = true; | 500 useMapSub = true; |
500 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") | 501 else if (extensions[i] == "GL_CHROMIUM_shallow_flush") |
501 m_useShallowFlush = true; | 502 m_useShallowFlush = true; |
502 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") | 503 else if (extensions[i] == "GL_CHROMIUM_bind_uniform_location") |
503 useBindUniform = true; | 504 useBindUniform = true; |
504 } | 505 } |
505 | 506 |
506 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub)); | 507 m_texSubImage = adoptPtr(new LayerTextureSubImage(useMapSub)); |
507 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform
); | 508 m_textureCopier = AcceleratedTextureCopier::create(context3d, useBindUniform
); |
508 | 509 |
509 m_textureUploader = ThrottledTextureUploader::create(context3d); | 510 m_textureUploader = ThrottledTextureUploader::create(context3d); |
510 GLC(context3d, context3d->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &
m_maxTextureSize)); | 511 GLC(context3d, context3d->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize
)); |
511 return true; | 512 return true; |
512 } | 513 } |
513 | 514 |
514 int CCResourceProvider::createChild(int pool) | 515 int CCResourceProvider::createChild(int pool) |
515 { | 516 { |
516 ASSERT(CCProxy::isImplThread()); | 517 ASSERT(CCProxy::isImplThread()); |
517 Child childInfo; | 518 Child childInfo; |
518 childInfo.pool = pool; | 519 childInfo.pool = pool; |
519 int child = m_nextChild++; | 520 int child = m_nextChild++; |
520 m_children.add(child, childInfo); | 521 m_children.add(child, childInfo); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); | 622 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); |
622 } | 623 } |
623 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | 624 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
624 Child& childInfo = m_children.find(child)->value; | 625 Child& childInfo = m_children.find(child)->value; |
625 #else | 626 #else |
626 Child& childInfo = m_children.find(child)->second; | 627 Child& childInfo = m_children.find(child)->second; |
627 #endif | 628 #endif |
628 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { | 629 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { |
629 unsigned textureId; | 630 unsigned textureId; |
630 GLC(context3d, textureId = context3d->createTexture()); | 631 GLC(context3d, textureId = context3d->createTexture()); |
631 GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, tex
tureId)); | 632 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
632 GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXT
URE_2D, it->mailbox.name)); | 633 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail
box.name)); |
633 ResourceId id = m_nextId++; | 634 ResourceId id = m_nextId++; |
634 Resource resource(textureId, childInfo.pool, it->size, it->format); | 635 Resource resource(textureId, childInfo.pool, it->size, it->format); |
635 m_resources.add(id, resource); | 636 m_resources.add(id, resource); |
636 m_mailboxes.append(it->mailbox); | 637 m_mailboxes.append(it->mailbox); |
637 childInfo.parentToChildMap.add(id, it->id); | 638 childInfo.parentToChildMap.add(id, it->id); |
638 childInfo.childToParentMap.add(it->id, id); | 639 childInfo.childToParentMap.add(it->id, id); |
639 } | 640 } |
640 } | 641 } |
641 | 642 |
642 void CCResourceProvider::receiveFromParent(const TransferableResourceList& resou
rces) | 643 void CCResourceProvider::receiveFromParent(const TransferableResourceList& resou
rces) |
643 { | 644 { |
644 ASSERT(CCProxy::isImplThread()); | 645 ASSERT(CCProxy::isImplThread()); |
645 WebGraphicsContext3D* context3d = m_context->context3D(); | 646 WebGraphicsContext3D* context3d = m_context->context3D(); |
646 if (!context3d || !context3d->makeContextCurrent()) { | 647 if (!context3d || !context3d->makeContextCurrent()) { |
647 // FIXME: Implement this path for software compositing. | 648 // FIXME: Implement this path for software compositing. |
648 return; | 649 return; |
649 } | 650 } |
650 if (resources.syncPoint) | 651 if (resources.syncPoint) |
651 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); | 652 GLC(context3d, context3d->waitSyncPoint(resources.syncPoint)); |
652 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { | 653 for (Vector<TransferableResource>::const_iterator it = resources.resources.b
egin(); it != resources.resources.end(); ++it) { |
653 ResourceMap::iterator mapIterator = m_resources.find(it->id); | 654 ResourceMap::iterator mapIterator = m_resources.find(it->id); |
654 ASSERT(mapIterator != m_resources.end()); | 655 ASSERT(mapIterator != m_resources.end()); |
655 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | 656 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
656 Resource* resource = &mapIterator->value; | 657 Resource* resource = &mapIterator->value; |
657 #else | 658 #else |
658 Resource* resource = &mapIterator->second; | 659 Resource* resource = &mapIterator->second; |
659 #endif | 660 #endif |
660 ASSERT(resource->exported); | 661 ASSERT(resource->exported); |
661 resource->exported = false; | 662 resource->exported = false; |
662 GLC(context3d, context3d->bindTexture(GraphicsContext3D::TEXTURE_2D, res
ource->glId)); | 663 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); |
663 GLC(context3d, context3d->consumeTextureCHROMIUM(GraphicsContext3D::TEXT
URE_2D, it->mailbox.name)); | 664 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail
box.name)); |
664 m_mailboxes.append(it->mailbox); | 665 m_mailboxes.append(it->mailbox); |
665 if (resource->markedForDeletion) | 666 if (resource->markedForDeletion) |
666 deleteResourceInternal(mapIterator); | 667 deleteResourceInternal(mapIterator); |
667 } | 668 } |
668 } | 669 } |
669 | 670 |
670 bool CCResourceProvider::transferResource(WebGraphicsContext3D* context, Resourc
eId id, TransferableResource* resource) | 671 bool CCResourceProvider::transferResource(WebGraphicsContext3D* context, Resourc
eId id, TransferableResource* resource) |
671 { | 672 { |
672 ASSERT(CCProxy::isImplThread()); | 673 ASSERT(CCProxy::isImplThread()); |
673 ResourceMap::const_iterator it = m_resources.find(id); | 674 ResourceMap::const_iterator it = m_resources.find(id); |
674 CHECK(it != m_resources.end()); | 675 CHECK(it != m_resources.end()); |
675 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE | 676 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE |
676 const Resource* source = &it->value; | 677 const Resource* source = &it->value; |
677 #else | 678 #else |
678 const Resource* source = &it->second; | 679 const Resource* source = &it->second; |
679 #endif | 680 #endif |
680 ASSERT(!source->lockedForWrite); | 681 ASSERT(!source->lockedForWrite); |
681 ASSERT(!source->lockForReadCount); | 682 ASSERT(!source->lockForReadCount); |
682 ASSERT(!source->external); | 683 ASSERT(!source->external); |
683 if (source->exported) | 684 if (source->exported) |
684 return false; | 685 return false; |
685 resource->id = id; | 686 resource->id = id; |
686 resource->format = source->format; | 687 resource->format = source->format; |
687 resource->size = source->size; | 688 resource->size = source->size; |
688 if (!m_mailboxes.isEmpty()) | 689 if (!m_mailboxes.isEmpty()) |
689 resource->mailbox = m_mailboxes.takeFirst(); | 690 resource->mailbox = m_mailboxes.takeFirst(); |
690 else | 691 else |
691 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); | 692 GLC(context, context->genMailboxCHROMIUM(resource->mailbox.name)); |
692 GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, source->glI
d)); | 693 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId)); |
693 GLC(context, context->produceTextureCHROMIUM(GraphicsContext3D::TEXTURE_2D,
resource->mailbox.name)); | 694 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbo
x.name)); |
694 return true; | 695 return true; |
695 } | 696 } |
696 | 697 |
697 void CCResourceProvider::trimMailboxDeque() | 698 void CCResourceProvider::trimMailboxDeque() |
698 { | 699 { |
699 // Trim the mailbox deque to the maximum number of resources we may need to | 700 // Trim the mailbox deque to the maximum number of resources we may need to |
700 // send. | 701 // send. |
701 // If we have a parent, any non-external resource not already transfered is | 702 // If we have a parent, any non-external resource not already transfered is |
702 // eligible to be sent to the parent. Otherwise, all resources belonging to | 703 // eligible to be sent to the parent. Otherwise, all resources belonging to |
703 // a child might need to be sent back to the child. | 704 // a child might need to be sent back to the child. |
(...skipping 22 matching lines...) Expand all Loading... |
726 if (ContainsKey(childPoolSet, it->second.pool)) | 727 if (ContainsKey(childPoolSet, it->second.pool)) |
727 #endif | 728 #endif |
728 ++maxMailboxCount; | 729 ++maxMailboxCount; |
729 } | 730 } |
730 } | 731 } |
731 while (m_mailboxes.size() > maxMailboxCount) | 732 while (m_mailboxes.size() > maxMailboxCount) |
732 m_mailboxes.removeFirst(); | 733 m_mailboxes.removeFirst(); |
733 } | 734 } |
734 | 735 |
735 } | 736 } |
OLD | NEW |