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 "cc/resource_provider.h" | 5 #include "cc/resource_provider.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 , glPixelBufferId(0) | 53 , glPixelBufferId(0) |
54 , glUploadQueryId(0) | 54 , glUploadQueryId(0) |
55 , pixels(0) | 55 , pixels(0) |
56 , pixelBuffer(0) | 56 , pixelBuffer(0) |
57 , lockForReadCount(0) | 57 , lockForReadCount(0) |
58 , lockedForWrite(false) | 58 , lockedForWrite(false) |
59 , external(false) | 59 , external(false) |
60 , exported(false) | 60 , exported(false) |
61 , markedForDeletion(false) | 61 , markedForDeletion(false) |
62 , pendingSetPixels(false) | 62 , pendingSetPixels(false) |
63 , allocated(false) | |
63 , size() | 64 , size() |
64 , format(0) | 65 , format(0) |
65 , filter(0) | 66 , filter(0) |
66 , type(static_cast<ResourceType>(0)) | 67 , type(static_cast<ResourceType>(0)) |
67 { | 68 { |
68 } | 69 } |
69 | 70 |
70 ResourceProvider::Resource::Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenum filter) | 71 ResourceProvider::Resource::Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenum filter) |
71 : glId(textureId) | 72 : glId(textureId) |
72 , glPixelBufferId(0) | 73 , glPixelBufferId(0) |
73 , glUploadQueryId(0) | 74 , glUploadQueryId(0) |
74 , pixels(0) | 75 , pixels(0) |
75 , pixelBuffer(0) | 76 , pixelBuffer(0) |
76 , lockForReadCount(0) | 77 , lockForReadCount(0) |
77 , lockedForWrite(false) | 78 , lockedForWrite(false) |
78 , external(false) | 79 , external(false) |
79 , exported(false) | 80 , exported(false) |
80 , markedForDeletion(false) | 81 , markedForDeletion(false) |
81 , pendingSetPixels(false) | 82 , pendingSetPixels(false) |
83 , allocated(false) | |
82 , size(size) | 84 , size(size) |
83 , format(format) | 85 , format(format) |
84 , filter(filter) | 86 , filter(filter) |
85 , type(GLTexture) | 87 , type(GLTexture) |
86 { | 88 { |
87 } | 89 } |
88 | 90 |
89 ResourceProvider::Resource::Resource(uint8_t* pixels, const gfx::Size& size, GLe num format, GLenum filter) | 91 ResourceProvider::Resource::Resource(uint8_t* pixels, const gfx::Size& size, GLe num format, GLenum filter) |
90 : glId(0) | 92 : glId(0) |
91 , glPixelBufferId(0) | 93 , glPixelBufferId(0) |
92 , glUploadQueryId(0) | 94 , glUploadQueryId(0) |
93 , pixels(pixels) | 95 , pixels(pixels) |
94 , pixelBuffer(0) | 96 , pixelBuffer(0) |
95 , lockForReadCount(0) | 97 , lockForReadCount(0) |
96 , lockedForWrite(false) | 98 , lockedForWrite(false) |
97 , external(false) | 99 , external(false) |
98 , exported(false) | 100 , exported(false) |
99 , markedForDeletion(false) | 101 , markedForDeletion(false) |
100 , pendingSetPixels(false) | 102 , pendingSetPixels(false) |
103 , allocated(false) | |
101 , size(size) | 104 , size(size) |
102 , format(format) | 105 , format(format) |
103 , filter(filter) | 106 , filter(filter) |
104 , type(Bitmap) | 107 , type(Bitmap) |
105 { | 108 { |
106 } | 109 } |
107 | 110 |
108 ResourceProvider::Child::Child() | 111 ResourceProvider::Child::Child() |
109 { | 112 { |
110 } | 113 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 { | 180 { |
178 DCHECK_LE(size.width(), m_maxTextureSize); | 181 DCHECK_LE(size.width(), m_maxTextureSize); |
179 DCHECK_LE(size.height(), m_maxTextureSize); | 182 DCHECK_LE(size.height(), m_maxTextureSize); |
180 | 183 |
181 DCHECK(m_threadChecker.CalledOnValidThread()); | 184 DCHECK(m_threadChecker.CalledOnValidThread()); |
182 unsigned textureId = 0; | 185 unsigned textureId = 0; |
183 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 186 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
184 DCHECK(context3d); | 187 DCHECK(context3d); |
185 GLC(context3d, textureId = context3d->createTexture()); | 188 GLC(context3d, textureId = context3d->createTexture()); |
186 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); | 189 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
190 | |
191 // Set texture properties. Allocation is delayed until needed. | |
187 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR)); | 192 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR)); |
188 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR)); | 193 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR)); |
189 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); | 194 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); |
190 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); | 195 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); |
191 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROM IUM, texturePool)); | 196 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROM IUM, texturePool)); |
192 | |
193 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) | 197 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) |
194 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); | 198 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); |
195 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { | |
196 GLenum storageFormat = textureToStorageFormat(format); | |
197 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height())); | |
198 } else | |
199 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); | |
200 | 199 |
201 ResourceId id = m_nextId++; | 200 ResourceId id = m_nextId++; |
202 Resource resource(textureId, size, format, GL_LINEAR); | 201 Resource resource(textureId, size, format, GL_LINEAR); |
202 resource.allocated = false; | |
203 m_resources[id] = resource; | 203 m_resources[id] = resource; |
204 return id; | 204 return id; |
205 } | 205 } |
206 | 206 |
207 ResourceProvider::ResourceId ResourceProvider::createBitmap(const gfx::Size& siz e) | 207 ResourceProvider::ResourceId ResourceProvider::createBitmap(const gfx::Size& siz e) |
208 { | 208 { |
209 DCHECK(m_threadChecker.CalledOnValidThread()); | 209 DCHECK(m_threadChecker.CalledOnValidThread()); |
210 | 210 |
211 uint8_t* pixels = new uint8_t[size.width() * size.height() * 4]; | 211 uint8_t* pixels = new uint8_t[size.width() * size.height() * 4]; |
212 | 212 |
213 ResourceId id = m_nextId++; | 213 ResourceId id = m_nextId++; |
214 Resource resource(pixels, size, GL_RGBA, GL_LINEAR); | 214 Resource resource(pixels, size, GL_RGBA, GL_LINEAR); |
215 resource.allocated = true; | |
215 m_resources[id] = resource; | 216 m_resources[id] = resource; |
216 return id; | 217 return id; |
217 } | 218 } |
218 | 219 |
219 ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture (unsigned textureId) | 220 ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture (unsigned textureId) |
220 { | 221 { |
221 DCHECK(m_threadChecker.CalledOnValidThread()); | 222 DCHECK(m_threadChecker.CalledOnValidThread()); |
222 | 223 |
223 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 224 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
224 DCHECK(context3d); | 225 DCHECK(context3d); |
225 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); | 226 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
226 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR)); | 227 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR)); |
227 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR)); | 228 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR)); |
228 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); | 229 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); |
229 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); | 230 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); |
230 | 231 |
231 ResourceId id = m_nextId++; | 232 ResourceId id = m_nextId++; |
232 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); | 233 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); |
233 resource.external = true; | 234 resource.external = true; |
235 resource.allocated = true; | |
234 m_resources[id] = resource; | 236 m_resources[id] = resource; |
235 return id; | 237 return id; |
236 } | 238 } |
237 | 239 |
238 void ResourceProvider::deleteResource(ResourceId id) | 240 void ResourceProvider::deleteResource(ResourceId id) |
239 { | 241 { |
240 DCHECK(m_threadChecker.CalledOnValidThread()); | 242 DCHECK(m_threadChecker.CalledOnValidThread()); |
241 ResourceMap::iterator it = m_resources.find(id); | 243 ResourceMap::iterator it = m_resources.find(id); |
242 CHECK(it != m_resources.end()); | 244 CHECK(it != m_resources.end()); |
243 Resource* resource = &it->second; | 245 Resource* resource = &it->second; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 DCHECK(m_threadChecker.CalledOnValidThread()); | 293 DCHECK(m_threadChecker.CalledOnValidThread()); |
292 ResourceMap::iterator it = m_resources.find(id); | 294 ResourceMap::iterator it = m_resources.find(id); |
293 CHECK(it != m_resources.end()); | 295 CHECK(it != m_resources.end()); |
294 Resource* resource = &it->second; | 296 Resource* resource = &it->second; |
295 DCHECK(!resource->lockedForWrite); | 297 DCHECK(!resource->lockedForWrite); |
296 DCHECK(!resource->lockForReadCount); | 298 DCHECK(!resource->lockForReadCount); |
297 DCHECK(!resource->external); | 299 DCHECK(!resource->external); |
298 DCHECK(!resource->exported); | 300 DCHECK(!resource->exported); |
299 | 301 |
300 if (resource->glId) { | 302 if (resource->glId) { |
303 DCHECK(!resource->pendingSetPixels); | |
301 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 304 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
302 DCHECK(context3d); | 305 DCHECK(context3d); |
303 DCHECK(m_textureUploader.get()); | 306 DCHECK(m_textureUploader.get()); |
304 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); | 307 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); |
308 | |
309 if (!resource->allocated) { | |
310 resource->allocated = true; | |
311 gfx::Size& size = resource->size; | |
312 GLenum format = resource->format; | |
313 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(forma t)) { | |
314 GLenum storageFormat = textureToStorageFormat(format); | |
315 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storag eFormat, size.width(), size.height())); | |
316 } else | |
317 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, siz e.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); | |
318 } | |
319 | |
305 m_textureUploader->upload(image, | 320 m_textureUploader->upload(image, |
306 imageRect, | 321 imageRect, |
307 sourceRect, | 322 sourceRect, |
308 destOffset, | 323 destOffset, |
309 resource->format, | 324 resource->format, |
310 resource->size); | 325 resource->size); |
311 } | 326 } |
312 | 327 |
313 if (resource->pixels) { | 328 if (resource->pixels) { |
329 DCHECK(resource->allocated); | |
314 DCHECK(resource->format == GL_RGBA); | 330 DCHECK(resource->format == GL_RGBA); |
315 SkBitmap srcFull; | 331 SkBitmap srcFull; |
316 srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageR ect.height()); | 332 srcFull.setConfig(SkBitmap::kARGB_8888_Config, imageRect.width(), imageR ect.height()); |
317 srcFull.setPixels(const_cast<uint8_t*>(image)); | 333 srcFull.setPixels(const_cast<uint8_t*>(image)); |
318 SkBitmap srcSubset; | 334 SkBitmap srcSubset; |
319 SkIRect skSourceRect = SkIRect::MakeXYWH(sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height()); | 335 SkIRect skSourceRect = SkIRect::MakeXYWH(sourceRect.x(), sourceRect.y(), sourceRect.width(), sourceRect.height()); |
320 skSourceRect.offset(-imageRect.x(), -imageRect.y()); | 336 skSourceRect.offset(-imageRect.x(), -imageRect.y()); |
321 srcFull.extractSubset(&srcSubset, skSourceRect); | 337 srcFull.extractSubset(&srcSubset, skSourceRect); |
322 | 338 |
323 ScopedWriteLockSoftware lock(this, id); | 339 ScopedWriteLockSoftware lock(this, id); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 } | 394 } |
379 | 395 |
380 const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id) | 396 const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id) |
381 { | 397 { |
382 DCHECK(m_threadChecker.CalledOnValidThread()); | 398 DCHECK(m_threadChecker.CalledOnValidThread()); |
383 ResourceMap::iterator it = m_resources.find(id); | 399 ResourceMap::iterator it = m_resources.find(id); |
384 CHECK(it != m_resources.end()); | 400 CHECK(it != m_resources.end()); |
385 Resource* resource = &it->second; | 401 Resource* resource = &it->second; |
386 DCHECK(!resource->lockedForWrite); | 402 DCHECK(!resource->lockedForWrite); |
387 DCHECK(!resource->exported); | 403 DCHECK(!resource->exported); |
404 DCHECK(resource->allocated); | |
388 resource->lockForReadCount++; | 405 resource->lockForReadCount++; |
389 return resource; | 406 return resource; |
390 } | 407 } |
391 | 408 |
392 void ResourceProvider::unlockForRead(ResourceId id) | 409 void ResourceProvider::unlockForRead(ResourceId id) |
393 { | 410 { |
394 DCHECK(m_threadChecker.CalledOnValidThread()); | 411 DCHECK(m_threadChecker.CalledOnValidThread()); |
395 ResourceMap::iterator it = m_resources.find(id); | 412 ResourceMap::iterator it = m_resources.find(id); |
396 CHECK(it != m_resources.end()); | 413 CHECK(it != m_resources.end()); |
397 Resource* resource = &it->second; | 414 Resource* resource = &it->second; |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 } | 656 } |
640 Child& childInfo = m_children.find(child)->second; | 657 Child& childInfo = m_children.find(child)->second; |
641 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) { | 658 for (TransferableResourceArray::const_iterator it = resources.resources.begi n(); it != resources.resources.end(); ++it) { |
642 unsigned textureId; | 659 unsigned textureId; |
643 GLC(context3d, textureId = context3d->createTexture()); | 660 GLC(context3d, textureId = context3d->createTexture()); |
644 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); | 661 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); |
645 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name)); | 662 GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mail box.name)); |
646 ResourceId id = m_nextId++; | 663 ResourceId id = m_nextId++; |
647 Resource resource(textureId, it->size, it->format, it->filter); | 664 Resource resource(textureId, it->size, it->format, it->filter); |
648 resource.mailbox.setName(it->mailbox.name); | 665 resource.mailbox.setName(it->mailbox.name); |
666 // Don't allocate a texture for a child. | |
667 resource.allocated = true; | |
649 m_resources[id] = resource; | 668 m_resources[id] = resource; |
650 childInfo.parentToChildMap[id] = it->id; | 669 childInfo.parentToChildMap[id] = it->id; |
651 childInfo.childToParentMap[it->id] = id; | 670 childInfo.childToParentMap[it->id] = id; |
652 } | 671 } |
653 } | 672 } |
654 | 673 |
655 void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc es) | 674 void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc es) |
656 { | 675 { |
657 DCHECK(m_threadChecker.CalledOnValidThread()); | 676 DCHECK(m_threadChecker.CalledOnValidThread()); |
658 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 677 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
(...skipping 20 matching lines...) Expand all Loading... | |
679 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI d id, TransferableResource* resource) | 698 bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceI d id, TransferableResource* resource) |
680 { | 699 { |
681 DCHECK(m_threadChecker.CalledOnValidThread()); | 700 DCHECK(m_threadChecker.CalledOnValidThread()); |
682 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 701 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
683 ResourceMap::iterator it = m_resources.find(id); | 702 ResourceMap::iterator it = m_resources.find(id); |
684 CHECK(it != m_resources.end()); | 703 CHECK(it != m_resources.end()); |
685 Resource* source = &it->second; | 704 Resource* source = &it->second; |
686 DCHECK(!source->lockedForWrite); | 705 DCHECK(!source->lockedForWrite); |
687 DCHECK(!source->lockForReadCount); | 706 DCHECK(!source->lockForReadCount); |
688 DCHECK(!source->external); | 707 DCHECK(!source->external); |
708 DCHECK(source->allocated); | |
689 if (source->exported) | 709 if (source->exported) |
690 return false; | 710 return false; |
691 resource->id = id; | 711 resource->id = id; |
692 resource->format = source->format; | 712 resource->format = source->format; |
693 resource->filter = source->filter; | 713 resource->filter = source->filter; |
694 resource->size = source->size; | 714 resource->size = source->size; |
695 | 715 |
696 if (source->mailbox.isZero()) { | 716 if (source->mailbox.isZero()) { |
697 GLbyte name[GL_MAILBOX_SIZE_CHROMIUM]; | 717 GLbyte name[GL_MAILBOX_SIZE_CHROMIUM]; |
698 GLC(context3d, context3d->genMailboxCHROMIUM(name)); | 718 GLC(context3d, context3d->genMailboxCHROMIUM(name)); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
832 DCHECK(!resource->lockedForWrite); | 852 DCHECK(!resource->lockedForWrite); |
833 DCHECK(!resource->lockForReadCount); | 853 DCHECK(!resource->lockForReadCount); |
834 DCHECK(!resource->external); | 854 DCHECK(!resource->external); |
835 DCHECK(!resource->exported); | 855 DCHECK(!resource->exported); |
836 | 856 |
837 if (resource->glId) { | 857 if (resource->glId) { |
838 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); | 858 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); |
839 DCHECK(context3d); | 859 DCHECK(context3d); |
840 DCHECK(resource->glPixelBufferId); | 860 DCHECK(resource->glPixelBufferId); |
841 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); | 861 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); |
862 | |
863 if (!resource->allocated) { | |
864 resource->allocated = true; | |
865 gfx::Size& size = resource->size; | |
866 GLenum format = resource->format; | |
867 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(forma t)) { | |
868 GLenum storageFormat = textureToStorageFormat(format); | |
869 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storag eFormat, size.width(), size.height())); | |
870 } else | |
871 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, siz e.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); | |
872 } | |
piman
2012/12/18 00:30:47
I'd prefer if this code was shared with the versio
epenner
2012/12/18 04:02:47
Done.
| |
873 | |
842 context3d->bindBuffer( | 874 context3d->bindBuffer( |
843 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 875 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
844 resource->glPixelBufferId); | 876 resource->glPixelBufferId); |
845 context3d->texSubImage2D(GL_TEXTURE_2D, | 877 context3d->texSubImage2D(GL_TEXTURE_2D, |
846 0, /* level */ | 878 0, /* level */ |
847 0, /* x */ | 879 0, /* x */ |
848 0, /* y */ | 880 0, /* y */ |
849 resource->size.width(), | 881 resource->size.width(), |
850 resource->size.height(), | 882 resource->size.height(), |
851 resource->format, | 883 resource->format, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 DCHECK(resource->glPixelBufferId); | 935 DCHECK(resource->glPixelBufferId); |
904 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); | 936 context3d->bindTexture(GL_TEXTURE_2D, resource->glId); |
905 context3d->bindBuffer( | 937 context3d->bindBuffer( |
906 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, | 938 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, |
907 resource->glPixelBufferId); | 939 resource->glPixelBufferId); |
908 if (!resource->glUploadQueryId) | 940 if (!resource->glUploadQueryId) |
909 resource->glUploadQueryId = context3d->createQueryEXT(); | 941 resource->glUploadQueryId = context3d->createQueryEXT(); |
910 context3d->beginQueryEXT( | 942 context3d->beginQueryEXT( |
911 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM, | 943 GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM, |
912 resource->glUploadQueryId); | 944 resource->glUploadQueryId); |
913 context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D, | 945 if (!resource->allocated) { |
914 0, /* level */ | 946 resource->allocated = true; |
915 0, /* x */ | 947 context3d->asyncTexImage2DCHROMIUM(GL_TEXTURE_2D, |
916 0, /* y */ | 948 0, /* level */ |
917 resource->size.width(), | 949 resource->format, |
918 resource->size.height(), | 950 resource->size.width(), |
919 resource->format, | 951 resource->size.height(), |
920 GL_UNSIGNED_BYTE, | 952 0, /* border */ |
921 NULL); | 953 resource->format, |
954 GL_UNSIGNED_BYTE, | |
955 NULL); | |
956 } else { | |
957 context3d->asyncTexSubImage2DCHROMIUM(GL_TEXTURE_2D, | |
958 0, /* level */ | |
959 0, /* x */ | |
960 0, /* y */ | |
961 resource->size.width(), | |
962 resource->size.height(), | |
963 resource->format, | |
964 GL_UNSIGNED_BYTE, | |
965 NULL); | |
966 } | |
922 context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM); | 967 context3d->endQueryEXT(GL_ASYNC_PIXEL_TRANSFERS_COMPLETED_CHROMIUM); |
923 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); | 968 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); |
924 } | 969 } |
925 | 970 |
926 if (resource->pixels) | 971 if (resource->pixels) |
927 setPixelsFromBuffer(id); | 972 setPixelsFromBuffer(id); |
928 | 973 |
929 resource->pendingSetPixels = true; | 974 resource->pendingSetPixels = true; |
930 } | 975 } |
931 | 976 |
(...skipping 18 matching lines...) Expand all Loading... | |
950 return false; | 995 return false; |
951 } | 996 } |
952 | 997 |
953 resource->pendingSetPixels = false; | 998 resource->pendingSetPixels = false; |
954 unlockForWrite(id); | 999 unlockForWrite(id); |
955 | 1000 |
956 return true; | 1001 return true; |
957 } | 1002 } |
958 | 1003 |
959 } // namespace cc | 1004 } // namespace cc |
OLD | NEW |