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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 562833004: cc: Move RasterBuffer implementations from ResourceProvider to RasterWorkerPool implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix Created 6 years, 3 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 // 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/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return kBGRA_8888_GrPixelConfig; 104 return kBGRA_8888_GrPixelConfig;
105 case RGBA_4444: 105 case RGBA_4444:
106 return kRGBA_4444_GrPixelConfig; 106 return kRGBA_4444_GrPixelConfig;
107 default: 107 default:
108 break; 108 break;
109 } 109 }
110 DCHECK(false) << "Unsupported resource format."; 110 DCHECK(false) << "Unsupported resource format.";
111 return kSkia8888_GrPixelConfig; 111 return kSkia8888_GrPixelConfig;
112 } 112 }
113 113
114 void MakeBitmap(SkBitmap* bitmap,
115 uint8_t* buffer,
116 ResourceFormat format,
117 const gfx::Size& size,
118 int stride) {
119 switch (format) {
120 case RGBA_4444:
121 // Use the default stride if we will eventually convert this
122 // bitmap to 4444.
123 bitmap->allocN32Pixels(size.width(), size.height());
124 break;
125 case RGBA_8888:
126 case BGRA_8888: {
127 SkImageInfo info =
128 SkImageInfo::MakeN32Premul(size.width(), size.height());
129 if (0 == stride)
130 stride = info.minRowBytes();
131 bitmap->installPixels(info, buffer, stride);
132 break;
133 }
134 case ALPHA_8:
135 case LUMINANCE_8:
136 case RGB_565:
137 case ETC1:
138 NOTREACHED();
139 break;
140 }
141 }
142
143 void CopyBitmap(const SkBitmap& src, uint8_t* dst, SkColorType dst_color_type) {
144 SkImageInfo dst_info = src.info();
145 dst_info.fColorType = dst_color_type;
146 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
147 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
148 // is fixed.
149 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
150 CHECK_EQ(0u, dst_row_bytes % 4);
151 bool success = src.readPixels(dst_info, dst, dst_row_bytes, 0, 0);
152 CHECK_EQ(true, success);
153 }
154
155 class ScopedSetActiveTexture { 114 class ScopedSetActiveTexture {
156 public: 115 public:
157 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit) 116 ScopedSetActiveTexture(GLES2Interface* gl, GLenum unit)
158 : gl_(gl), unit_(unit) { 117 : gl_(gl), unit_(unit) {
159 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_)); 118 DCHECK_EQ(GL_TEXTURE0, ResourceProvider::GetActiveTextureUnit(gl_));
160 119
161 if (unit_ != GL_TEXTURE0) 120 if (unit_ != GL_TEXTURE0)
162 GLC(gl_, gl_->ActiveTexture(unit_)); 121 GLC(gl_, gl_->ActiveTexture(unit_));
163 } 122 }
164 123
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 texture_pool(0), 370 texture_pool(0),
412 wrap_mode(wrap_mode), 371 wrap_mode(wrap_mode),
413 hint(TextureHintImmutable), 372 hint(TextureHintImmutable),
414 type(Bitmap), 373 type(Bitmap),
415 format(RGBA_8888), 374 format(RGBA_8888),
416 shared_bitmap_id(bitmap_id), 375 shared_bitmap_id(bitmap_id),
417 shared_bitmap(NULL) { 376 shared_bitmap(NULL) {
418 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT); 377 DCHECK(wrap_mode == GL_CLAMP_TO_EDGE || wrap_mode == GL_REPEAT);
419 } 378 }
420 379
421 ResourceProvider::GpuRasterBuffer::GpuRasterBuffer(
422 const Resource* resource,
423 ResourceProvider* resource_provider,
424 bool use_distance_field_text)
425 : resource_(resource), resource_provider_(resource_provider) {
426 DCHECK_EQ(GLTexture, resource_->type);
427 DCHECK(resource_->gl_id);
428
429 class GrContext* gr_context = resource_provider_->GrContext();
430 // TODO(alokp): Implement TestContextProvider::GrContext().
431 if (gr_context) {
432 GrBackendTextureDesc desc;
433 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
434 desc.fWidth = resource_->size.width();
435 desc.fHeight = resource_->size.height();
436 desc.fConfig = ToGrPixelConfig(resource_->format);
437 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
438 desc.fTextureHandle = resource_->gl_id;
439 skia::RefPtr<GrTexture> gr_texture =
440 skia::AdoptRef(gr_context->wrapBackendTexture(desc));
441 SkSurface::TextRenderMode text_render_mode =
442 use_distance_field_text ? SkSurface::kDistanceField_TextRenderMode
443 : SkSurface::kStandard_TextRenderMode;
444 surface_ = skia::AdoptRef(SkSurface::NewRenderTargetDirect(
445 gr_texture->asRenderTarget(), text_render_mode));
446 }
447 }
448
449 ResourceProvider::GpuRasterBuffer::~GpuRasterBuffer() {
450 }
451
452 skia::RefPtr<SkCanvas> ResourceProvider::GpuRasterBuffer::AcquireSkCanvas() {
453 // Note that this function is called from a worker thread.
454 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
455 "ResourceProvider::GpuRasterBuffer::AcquireSkCanvas");
456
457 return surface_ ? skia::SharePtr(surface_->getCanvas())
458 : skia::RefPtr<SkCanvas>();
459 }
460
461 void ResourceProvider::GpuRasterBuffer::ReleaseSkCanvas(
462 const skia::RefPtr<SkCanvas>& canvas) {
463 // Note that this function is called from a worker thread.
464 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
465 "ResourceProvider::GpuRasterBuffer::ReleaseSkCanvas");
466 }
467
468 ResourceProvider::ImageRasterBuffer::ImageRasterBuffer(
469 const Resource* resource,
470 ResourceProvider* resource_provider)
471 : resource_(resource),
472 resource_provider_(resource_provider),
473 mapped_buffer_(NULL),
474 raster_bitmap_changed_(false),
475 stride_(0) {
476 }
477
478 ResourceProvider::ImageRasterBuffer::~ImageRasterBuffer() {
479 }
480
481 void ResourceProvider::ImageRasterBuffer::MapBuffer() {
482 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
483 "ResourceProvider::ImageRasterBuffer::MapBuffer");
484
485 DCHECK(!mapped_buffer_);
486
487 stride_ = 0;
488 mapped_buffer_ = resource_provider_->MapImage(resource_, &stride_);
489 raster_bitmap_changed_ = false;
490 }
491
492 bool ResourceProvider::ImageRasterBuffer::UnmapBuffer() {
493 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
494 "ResourceProvider::ImageRasterBuffer::UnmapBuffer");
495
496 if (mapped_buffer_) {
497 resource_provider_->UnmapImage(resource_);
498 mapped_buffer_ = NULL;
499 }
500 return raster_bitmap_changed_;
501 }
502
503 skia::RefPtr<SkCanvas> ResourceProvider::ImageRasterBuffer::AcquireSkCanvas() {
504 // Note that this function is called from a worker thread.
505 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
506 "ResourceProvider::ImageRasterBuffer::AcquireSkCanvas");
507
508 if (!mapped_buffer_)
509 return skia::RefPtr<SkCanvas>();
510
511 MakeBitmap(&raster_bitmap_,
512 mapped_buffer_,
513 resource_->format,
514 resource_->size,
515 stride_);
516 raster_bitmap_changed_ = true;
517 return skia::AdoptRef(new SkCanvas(raster_bitmap_));
518 }
519
520 void ResourceProvider::ImageRasterBuffer::ReleaseSkCanvas(
521 const skia::RefPtr<SkCanvas>& canvas) {
522 // Note that this function is called from a worker thread.
523 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
524 "ResourceProvider::ImageRasterBuffer::ReleaseSkCanvas");
525
526 SkColorType buffer_colorType = ResourceFormatToSkColorType(resource_->format);
527 if (mapped_buffer_ && (buffer_colorType != raster_bitmap_.colorType()))
528 CopyBitmap(raster_bitmap_, mapped_buffer_, buffer_colorType);
529 raster_bitmap_.reset();
530 }
531
532 ResourceProvider::PixelRasterBuffer::PixelRasterBuffer(
533 const Resource* resource,
534 ResourceProvider* resource_provider)
535 : resource_(resource),
536 resource_provider_(resource_provider),
537 mapped_buffer_(NULL),
538 raster_bitmap_changed_(false),
539 stride_(0) {
540 }
541
542 ResourceProvider::PixelRasterBuffer::~PixelRasterBuffer() {
543 }
544
545 void ResourceProvider::PixelRasterBuffer::MapBuffer() {
546 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
547 "ResourceProvider::PixelRasterBuffer::MapBuffer");
548
549 DCHECK(!mapped_buffer_);
550
551 stride_ = 0;
552 mapped_buffer_ = resource_provider_->MapPixelBuffer(resource_, &stride_);
553 raster_bitmap_changed_ = false;
554 }
555
556 bool ResourceProvider::PixelRasterBuffer::UnmapBuffer() {
557 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
558 "ResourceProvider::PixelRasterBuffer::UnmapBuffer");
559
560 if (mapped_buffer_) {
561 resource_provider_->UnmapPixelBuffer(resource_);
562 mapped_buffer_ = NULL;
563 }
564 return raster_bitmap_changed_;
565 }
566
567 skia::RefPtr<SkCanvas> ResourceProvider::PixelRasterBuffer::AcquireSkCanvas() {
568 // Note that this function is called from a worker thread.
569 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
570 "ResourceProvider::PixelRasterBuffer::AcquireSkCanvas");
571
572 if (!mapped_buffer_)
573 return skia::RefPtr<SkCanvas>();
574
575 MakeBitmap(&raster_bitmap_,
576 mapped_buffer_,
577 resource_->format,
578 resource_->size,
579 stride_);
580 raster_bitmap_changed_ = true;
581 return skia::AdoptRef(new SkCanvas(raster_bitmap_));
582 }
583
584 void ResourceProvider::PixelRasterBuffer::ReleaseSkCanvas(
585 const skia::RefPtr<SkCanvas>& canvas) {
586 // Note that this function is called from a worker thread.
587 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
588 "ResourceProvider::PixelRasterBuffer::ReleaseSkCanvas");
589
590 SkColorType buffer_colorType = ResourceFormatToSkColorType(resource_->format);
591 if (mapped_buffer_ && (buffer_colorType != raster_bitmap_.colorType()))
592 CopyBitmap(raster_bitmap_, mapped_buffer_, buffer_colorType);
593 raster_bitmap_.reset();
594 }
595
596 ResourceProvider::Child::Child() : marked_for_deletion(false) {} 380 ResourceProvider::Child::Child() : marked_for_deletion(false) {}
597 381
598 ResourceProvider::Child::~Child() {} 382 ResourceProvider::Child::~Child() {}
599 383
600 scoped_ptr<ResourceProvider> ResourceProvider::Create( 384 scoped_ptr<ResourceProvider> ResourceProvider::Create(
601 OutputSurface* output_surface, 385 OutputSurface* output_surface,
602 SharedBitmapManager* shared_bitmap_manager, 386 SharedBitmapManager* shared_bitmap_manager,
603 BlockingTaskRunner* blocking_main_thread_task_runner, 387 BlockingTaskRunner* blocking_main_thread_task_runner,
604 int highp_threshold_min, 388 int highp_threshold_min,
605 bool use_rgba_4444_texture_format, 389 bool use_rgba_4444_texture_format,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it, 625 void ResourceProvider::DeleteResourceInternal(ResourceMap::iterator it,
842 DeleteStyle style) { 626 DeleteStyle style) {
843 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal"); 627 TRACE_EVENT0("cc", "ResourceProvider::DeleteResourceInternal");
844 Resource* resource = &it->second; 628 Resource* resource = &it->second;
845 bool lost_resource = resource->lost; 629 bool lost_resource = resource->lost;
846 630
847 DCHECK(resource->exported_count == 0 || style != Normal); 631 DCHECK(resource->exported_count == 0 || style != Normal);
848 if (style == ForShutdown && resource->exported_count > 0) 632 if (style == ForShutdown && resource->exported_count > 0)
849 lost_resource = true; 633 lost_resource = true;
850 634
851 resource->gpu_raster_buffer.reset();
852 resource->image_raster_buffer.reset();
853 resource->pixel_raster_buffer.reset();
854
855 if (resource->image_id) { 635 if (resource->image_id) {
856 DCHECK(resource->origin == Resource::Internal); 636 DCHECK(resource->origin == Resource::Internal);
857 GLES2Interface* gl = ContextGL(); 637 GLES2Interface* gl = ContextGL();
858 DCHECK(gl); 638 DCHECK(gl);
859 GLC(gl, gl->DestroyImageCHROMIUM(resource->image_id)); 639 GLC(gl, gl->DestroyImageCHROMIUM(resource->image_id));
860 } 640 }
861 if (resource->gl_upload_query_id) { 641 if (resource->gl_upload_query_id) {
862 DCHECK(resource->origin == Resource::Internal); 642 DCHECK(resource->origin == Resource::Internal);
863 GLES2Interface* gl = ContextGL(); 643 GLES2Interface* gl = ContextGL();
864 DCHECK(gl); 644 DCHECK(gl);
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 child_info->return_callback.Run(to_return, 1525 child_info->return_callback.Run(to_return,
1746 blocking_main_thread_task_runner_); 1526 blocking_main_thread_task_runner_);
1747 1527
1748 if (child_info->marked_for_deletion && 1528 if (child_info->marked_for_deletion &&
1749 child_info->parent_to_child_map.empty()) { 1529 child_info->parent_to_child_map.empty()) {
1750 DCHECK(child_info->child_to_parent_map.empty()); 1530 DCHECK(child_info->child_to_parent_map.empty());
1751 children_.erase(child_it); 1531 children_.erase(child_it);
1752 } 1532 }
1753 } 1533 }
1754 1534
1755 RasterBuffer* ResourceProvider::AcquireGpuRasterBuffer(ResourceId id) { 1535 void ResourceProvider::AcquirePixelBuffer(ResourceId id) {
1756 // Resource needs to be locked for write since GpuRasterBuffer writes
1757 // directly to it.
1758 LockForWrite(id);
1759 Resource* resource = GetResource(id);
1760 if (!resource->gpu_raster_buffer.get()) {
1761 resource->gpu_raster_buffer.reset(
1762 new GpuRasterBuffer(resource, this, use_distance_field_text_));
1763 }
1764 return resource->gpu_raster_buffer.get();
1765 }
1766
1767 void ResourceProvider::ReleaseGpuRasterBuffer(ResourceId id) {
1768 Resource* resource = GetResource(id);
1769 DCHECK(resource->gpu_raster_buffer.get());
1770 UnlockForWrite(id);
1771 }
1772
1773 RasterBuffer* ResourceProvider::AcquireImageRasterBuffer(ResourceId id) {
1774 Resource* resource = GetResource(id);
1775 AcquireImage(resource);
1776 if (!resource->image_raster_buffer.get())
1777 resource->image_raster_buffer.reset(new ImageRasterBuffer(resource, this));
1778 resource->image_raster_buffer->MapBuffer();
1779 return resource->image_raster_buffer.get();
1780 }
1781
1782 bool ResourceProvider::ReleaseImageRasterBuffer(ResourceId id) {
1783 Resource* resource = GetResource(id);
1784 resource->dirty_image = true;
1785 return resource->image_raster_buffer->UnmapBuffer();
1786 }
1787
1788 RasterBuffer* ResourceProvider::AcquirePixelRasterBuffer(ResourceId id) {
1789 Resource* resource = GetResource(id);
1790 AcquirePixelBuffer(resource);
1791 resource->pixel_raster_buffer.reset(new PixelRasterBuffer(resource, this));
1792 resource->pixel_raster_buffer->MapBuffer();
1793 return resource->pixel_raster_buffer.get();
1794 }
1795
1796 bool ResourceProvider::ReleasePixelRasterBuffer(ResourceId id) {
1797 Resource* resource = GetResource(id);
1798 DCHECK(resource->pixel_raster_buffer.get());
1799 bool raster_bitmap_changed = resource->pixel_raster_buffer->UnmapBuffer();
1800 resource->pixel_raster_buffer.reset();
1801 ReleasePixelBuffer(resource);
1802 return raster_bitmap_changed;
1803 }
1804
1805 void ResourceProvider::AcquirePixelBuffer(Resource* resource) {
1806 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1536 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1807 "ResourceProvider::AcquirePixelBuffer"); 1537 "ResourceProvider::AcquirePixelBuffer");
1808 1538
1539 Resource* resource = GetResource(id);
1809 DCHECK(resource->origin == Resource::Internal); 1540 DCHECK(resource->origin == Resource::Internal);
1810 DCHECK_EQ(resource->exported_count, 0); 1541 DCHECK_EQ(resource->exported_count, 0);
1811 DCHECK(!resource->image_id); 1542 DCHECK(!resource->image_id);
1812 DCHECK_NE(ETC1, resource->format); 1543 DCHECK_NE(ETC1, resource->format);
1813 1544
1814 DCHECK_EQ(GLTexture, resource->type); 1545 DCHECK_EQ(GLTexture, resource->type);
1815 GLES2Interface* gl = ContextGL(); 1546 GLES2Interface* gl = ContextGL();
1816 DCHECK(gl); 1547 DCHECK(gl);
1817 if (!resource->gl_pixel_buffer_id) 1548 if (!resource->gl_pixel_buffer_id)
1818 resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId(); 1549 resource->gl_pixel_buffer_id = buffer_id_allocator_->NextId();
1819 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1550 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1820 resource->gl_pixel_buffer_id); 1551 resource->gl_pixel_buffer_id);
1821 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8; 1552 unsigned bytes_per_pixel = BitsPerPixel(resource->format) / 8;
1822 gl->BufferData(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1553 gl->BufferData(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1823 resource->size.height() * 1554 resource->size.height() *
1824 RoundUp(bytes_per_pixel * resource->size.width(), 4u), 1555 RoundUp(bytes_per_pixel * resource->size.width(), 4u),
1825 NULL, 1556 NULL,
1826 GL_DYNAMIC_DRAW); 1557 GL_DYNAMIC_DRAW);
1827 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1558 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1828 } 1559 }
1829 1560
1830 void ResourceProvider::ReleasePixelBuffer(Resource* resource) { 1561 void ResourceProvider::ReleasePixelBuffer(ResourceId id) {
1831 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1562 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1832 "ResourceProvider::ReleasePixelBuffer"); 1563 "ResourceProvider::ReleasePixelBuffer");
1833 1564
1565 Resource* resource = GetResource(id);
1834 DCHECK(resource->origin == Resource::Internal); 1566 DCHECK(resource->origin == Resource::Internal);
1835 DCHECK_EQ(resource->exported_count, 0); 1567 DCHECK_EQ(resource->exported_count, 0);
1836 DCHECK(!resource->image_id); 1568 DCHECK(!resource->image_id);
1837 1569
1838 // The pixel buffer can be released while there is a pending "set pixels" 1570 // The pixel buffer can be released while there is a pending "set pixels"
1839 // if completion has been forced. Any shared memory associated with this 1571 // if completion has been forced. Any shared memory associated with this
1840 // pixel buffer will not be freed until the waitAsyncTexImage2DCHROMIUM 1572 // pixel buffer will not be freed until the waitAsyncTexImage2DCHROMIUM
1841 // command has been processed on the service side. It is also safe to 1573 // command has been processed on the service side. It is also safe to
1842 // reuse any query id associated with this resource before they complete 1574 // reuse any query id associated with this resource before they complete
1843 // as each new query has a unique submit count. 1575 // as each new query has a unique submit count.
1844 if (resource->pending_set_pixels) { 1576 if (resource->pending_set_pixels) {
1845 DCHECK(resource->set_pixels_completion_forced); 1577 DCHECK(resource->set_pixels_completion_forced);
1846 resource->pending_set_pixels = false; 1578 resource->pending_set_pixels = false;
1847 resource->locked_for_write = false; 1579 resource->locked_for_write = false;
1848 } 1580 }
1849 1581
1850 DCHECK_EQ(GLTexture, resource->type); 1582 DCHECK_EQ(GLTexture, resource->type);
1851 if (!resource->gl_pixel_buffer_id) 1583 if (!resource->gl_pixel_buffer_id)
1852 return; 1584 return;
1853 GLES2Interface* gl = ContextGL(); 1585 GLES2Interface* gl = ContextGL();
1854 DCHECK(gl); 1586 DCHECK(gl);
1855 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1587 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1856 resource->gl_pixel_buffer_id); 1588 resource->gl_pixel_buffer_id);
1857 gl->BufferData( 1589 gl->BufferData(
1858 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0, NULL, GL_DYNAMIC_DRAW); 1590 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0, NULL, GL_DYNAMIC_DRAW);
1859 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1591 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1860 } 1592 }
1861 1593
1862 uint8_t* ResourceProvider::MapPixelBuffer(const Resource* resource, 1594 uint8_t* ResourceProvider::MapPixelBuffer(ResourceId id, int* stride) {
1863 int* stride) {
1864 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1595 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1865 "ResourceProvider::MapPixelBuffer"); 1596 "ResourceProvider::MapPixelBuffer");
1866 1597
1598 Resource* resource = GetResource(id);
1867 DCHECK(resource->origin == Resource::Internal); 1599 DCHECK(resource->origin == Resource::Internal);
1868 DCHECK_EQ(resource->exported_count, 0); 1600 DCHECK_EQ(resource->exported_count, 0);
1869 DCHECK(!resource->image_id); 1601 DCHECK(!resource->image_id);
1870 1602
1871 *stride = 0; 1603 *stride = 0;
1872 DCHECK_EQ(GLTexture, resource->type); 1604 DCHECK_EQ(GLTexture, resource->type);
1873 GLES2Interface* gl = ContextGL(); 1605 GLES2Interface* gl = ContextGL();
1874 DCHECK(gl); 1606 DCHECK(gl);
1875 DCHECK(resource->gl_pixel_buffer_id); 1607 DCHECK(resource->gl_pixel_buffer_id);
1876 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1608 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1877 resource->gl_pixel_buffer_id); 1609 resource->gl_pixel_buffer_id);
1878 uint8_t* image = static_cast<uint8_t*>(gl->MapBufferCHROMIUM( 1610 uint8_t* image = static_cast<uint8_t*>(gl->MapBufferCHROMIUM(
1879 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY)); 1611 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, GL_WRITE_ONLY));
1880 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1612 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1881 // Buffer is required to be 4-byte aligned. 1613 // Buffer is required to be 4-byte aligned.
1882 CHECK(!(reinterpret_cast<intptr_t>(image) & 3)); 1614 CHECK(!(reinterpret_cast<intptr_t>(image) & 3));
1883 return image; 1615 return image;
1884 } 1616 }
1885 1617
1886 void ResourceProvider::UnmapPixelBuffer(const Resource* resource) { 1618 void ResourceProvider::UnmapPixelBuffer(ResourceId id) {
1887 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1619 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1888 "ResourceProvider::UnmapPixelBuffer"); 1620 "ResourceProvider::UnmapPixelBuffer");
1889 1621
1622 Resource* resource = GetResource(id);
1890 DCHECK(resource->origin == Resource::Internal); 1623 DCHECK(resource->origin == Resource::Internal);
1891 DCHECK_EQ(resource->exported_count, 0); 1624 DCHECK_EQ(resource->exported_count, 0);
1892 DCHECK(!resource->image_id); 1625 DCHECK(!resource->image_id);
1893 1626
1894 DCHECK_EQ(GLTexture, resource->type); 1627 DCHECK_EQ(GLTexture, resource->type);
1895 GLES2Interface* gl = ContextGL(); 1628 GLES2Interface* gl = ContextGL();
1896 DCHECK(gl); 1629 DCHECK(gl);
1897 DCHECK(resource->gl_pixel_buffer_id); 1630 DCHECK(resource->gl_pixel_buffer_id);
1898 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 1631 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
1899 resource->gl_pixel_buffer_id); 1632 resource->gl_pixel_buffer_id);
1900 gl->UnmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM); 1633 gl->UnmapBufferCHROMIUM(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM);
1901 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 1634 gl->BindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
1902 } 1635 }
1903 1636
1904 GLenum ResourceProvider::BindForSampling( 1637 GLenum ResourceProvider::BindForSampling(ResourceId resource_id,
1905 ResourceProvider::ResourceId resource_id, 1638 GLenum unit,
1906 GLenum unit, 1639 GLenum filter) {
1907 GLenum filter) {
1908 DCHECK(thread_checker_.CalledOnValidThread()); 1640 DCHECK(thread_checker_.CalledOnValidThread());
1909 GLES2Interface* gl = ContextGL(); 1641 GLES2Interface* gl = ContextGL();
1910 ResourceMap::iterator it = resources_.find(resource_id); 1642 ResourceMap::iterator it = resources_.find(resource_id);
1911 DCHECK(it != resources_.end()); 1643 DCHECK(it != resources_.end());
1912 Resource* resource = &it->second; 1644 Resource* resource = &it->second;
1913 DCHECK(resource->lock_for_read_count); 1645 DCHECK(resource->lock_for_read_count);
1914 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced); 1646 DCHECK(!resource->locked_for_write || resource->set_pixels_completion_forced);
1915 1647
1916 ScopedSetActiveTexture scoped_active_tex(gl, unit); 1648 ScopedSetActiveTexture scoped_active_tex(gl, unit);
1917 GLenum target = resource->target; 1649 GLenum target = resource->target;
(...skipping 10 matching lines...) Expand all
1928 return target; 1660 return target;
1929 } 1661 }
1930 1662
1931 void ResourceProvider::BeginSetPixels(ResourceId id) { 1663 void ResourceProvider::BeginSetPixels(ResourceId id) {
1932 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1664 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1933 "ResourceProvider::BeginSetPixels"); 1665 "ResourceProvider::BeginSetPixels");
1934 1666
1935 Resource* resource = GetResource(id); 1667 Resource* resource = GetResource(id);
1936 DCHECK(!resource->pending_set_pixels); 1668 DCHECK(!resource->pending_set_pixels);
1937 1669
1938 DCHECK(resource->pixel_raster_buffer.get());
1939 bool raster_bitmap_changed = resource->pixel_raster_buffer->UnmapBuffer();
1940 if (!raster_bitmap_changed)
1941 return;
1942
1943 LazyCreate(resource); 1670 LazyCreate(resource);
1944 DCHECK(resource->origin == Resource::Internal); 1671 DCHECK(resource->origin == Resource::Internal);
1945 DCHECK(resource->gl_id || resource->allocated); 1672 DCHECK(resource->gl_id || resource->allocated);
1946 DCHECK(ReadLockFenceHasPassed(resource)); 1673 DCHECK(ReadLockFenceHasPassed(resource));
1947 DCHECK(!resource->image_id); 1674 DCHECK(!resource->image_id);
1948 1675
1949 bool allocate = !resource->allocated; 1676 bool allocate = !resource->allocated;
1950 resource->allocated = true; 1677 resource->allocated = true;
1951 LockForWrite(id); 1678 LockForWrite(id);
1952 1679
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 resource->pending_set_pixels = true; 1717 resource->pending_set_pixels = true;
1991 resource->set_pixels_completion_forced = false; 1718 resource->set_pixels_completion_forced = false;
1992 } 1719 }
1993 1720
1994 void ResourceProvider::ForceSetPixelsToComplete(ResourceId id) { 1721 void ResourceProvider::ForceSetPixelsToComplete(ResourceId id) {
1995 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1722 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
1996 "ResourceProvider::ForceSetPixelsToComplete"); 1723 "ResourceProvider::ForceSetPixelsToComplete");
1997 1724
1998 Resource* resource = GetResource(id); 1725 Resource* resource = GetResource(id);
1999 1726
2000 if (!resource->pending_set_pixels)
2001 return;
2002
2003 DCHECK(resource->locked_for_write); 1727 DCHECK(resource->locked_for_write);
1728 DCHECK(resource->pending_set_pixels);
2004 DCHECK(!resource->set_pixels_completion_forced); 1729 DCHECK(!resource->set_pixels_completion_forced);
2005 1730
2006 if (resource->gl_id) { 1731 if (resource->gl_id) {
2007 GLES2Interface* gl = ContextGL(); 1732 GLES2Interface* gl = ContextGL();
2008 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); 1733 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id));
2009 GLC(gl, gl->WaitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D)); 1734 GLC(gl, gl->WaitAsyncTexImage2DCHROMIUM(GL_TEXTURE_2D));
2010 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, 0)); 1735 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, 0));
2011 } 1736 }
2012 1737
2013 resource->set_pixels_completion_forced = true; 1738 resource->set_pixels_completion_forced = true;
2014 } 1739 }
2015 1740
2016 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) { 1741 bool ResourceProvider::DidSetPixelsComplete(ResourceId id) {
2017 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 1742 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
2018 "ResourceProvider::DidSetPixelsComplete"); 1743 "ResourceProvider::DidSetPixelsComplete");
2019 1744
2020 Resource* resource = GetResource(id); 1745 Resource* resource = GetResource(id);
2021 1746
2022 // Upload can be avoided as a result of raster bitmap not being modified.
2023 // Assume the upload was completed in that case.
2024 if (!resource->pending_set_pixels)
2025 return true;
2026
2027 DCHECK(resource->locked_for_write); 1747 DCHECK(resource->locked_for_write);
1748 DCHECK(resource->pending_set_pixels);
2028 1749
2029 if (resource->gl_id) { 1750 if (resource->gl_id) {
2030 GLES2Interface* gl = ContextGL(); 1751 GLES2Interface* gl = ContextGL();
2031 DCHECK(gl); 1752 DCHECK(gl);
2032 DCHECK(resource->gl_upload_query_id); 1753 DCHECK(resource->gl_upload_query_id);
2033 GLuint complete = 1; 1754 GLuint complete = 1;
2034 gl->GetQueryObjectuivEXT( 1755 gl->GetQueryObjectuivEXT(
2035 resource->gl_upload_query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete); 1756 resource->gl_upload_query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete);
2036 if (!complete) 1757 if (!complete)
2037 return false; 1758 return false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); 1812 GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
2092 } 1813 }
2093 } 1814 }
2094 1815
2095 void ResourceProvider::AllocateForTesting(ResourceId id) { 1816 void ResourceProvider::AllocateForTesting(ResourceId id) {
2096 LazyAllocate(GetResource(id)); 1817 LazyAllocate(GetResource(id));
2097 } 1818 }
2098 1819
2099 void ResourceProvider::LazyAllocate(Resource* resource) { 1820 void ResourceProvider::LazyAllocate(Resource* resource) {
2100 DCHECK(resource); 1821 DCHECK(resource);
1822 if (resource->allocated)
1823 return;
2101 LazyCreate(resource); 1824 LazyCreate(resource);
2102 1825 if (!resource->gl_id)
2103 DCHECK(resource->gl_id || resource->allocated);
2104 if (resource->allocated || !resource->gl_id)
2105 return; 1826 return;
2106 resource->allocated = true; 1827 resource->allocated = true;
2107 GLES2Interface* gl = ContextGL(); 1828 GLES2Interface* gl = ContextGL();
2108 gfx::Size& size = resource->size; 1829 gfx::Size& size = resource->size;
2109 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); 1830 DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D));
2110 ResourceFormat format = resource->format; 1831 ResourceFormat format = resource->format;
2111 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id)); 1832 GLC(gl, gl->BindTexture(GL_TEXTURE_2D, resource->gl_id));
2112 if (use_texture_storage_ext_ && 1833 if (use_texture_storage_ext_ &&
2113 IsFormatSupportedForStorage(format, use_texture_format_bgra_) && 1834 IsFormatSupportedForStorage(format, use_texture_format_bgra_) &&
2114 (resource->hint & TextureHintImmutable)) { 1835 (resource->hint & TextureHintImmutable)) {
(...skipping 24 matching lines...) Expand all
2139 DCHECK(resource->image_id); 1860 DCHECK(resource->image_id);
2140 1861
2141 // Release image currently bound to texture. 1862 // Release image currently bound to texture.
2142 if (resource->bound_image_id) 1863 if (resource->bound_image_id)
2143 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id); 1864 gl->ReleaseTexImage2DCHROMIUM(resource->target, resource->bound_image_id);
2144 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id); 1865 gl->BindTexImage2DCHROMIUM(resource->target, resource->image_id);
2145 resource->bound_image_id = resource->image_id; 1866 resource->bound_image_id = resource->image_id;
2146 resource->dirty_image = false; 1867 resource->dirty_image = false;
2147 } 1868 }
2148 1869
2149 void ResourceProvider::EnableReadLockFences(ResourceProvider::ResourceId id) { 1870 void ResourceProvider::EnableReadLockFences(ResourceId id) {
2150 Resource* resource = GetResource(id); 1871 Resource* resource = GetResource(id);
2151 resource->read_lock_fences_enabled = true; 1872 resource->read_lock_fences_enabled = true;
2152 } 1873 }
2153 1874
2154 void ResourceProvider::AcquireImage(Resource* resource) { 1875 void ResourceProvider::AcquireImage(ResourceId id) {
1876 Resource* resource = GetResource(id);
2155 DCHECK(resource->origin == Resource::Internal); 1877 DCHECK(resource->origin == Resource::Internal);
2156 DCHECK_EQ(resource->exported_count, 0); 1878 DCHECK_EQ(resource->exported_count, 0);
2157 1879
2158 if (resource->type != GLTexture) 1880 if (resource->type != GLTexture)
2159 return; 1881 return;
2160 1882
2161 if (resource->image_id) 1883 if (resource->image_id)
2162 return; 1884 return;
2163 1885
2164 resource->allocated = true; 1886 resource->allocated = true;
2165 GLES2Interface* gl = ContextGL(); 1887 GLES2Interface* gl = ContextGL();
2166 DCHECK(gl); 1888 DCHECK(gl);
2167 resource->image_id = 1889 resource->image_id =
2168 gl->CreateImageCHROMIUM(resource->size.width(), 1890 gl->CreateImageCHROMIUM(resource->size.width(),
2169 resource->size.height(), 1891 resource->size.height(),
2170 TextureToStorageFormat(resource->format), 1892 TextureToStorageFormat(resource->format),
2171 GL_IMAGE_MAP_CHROMIUM); 1893 GL_IMAGE_MAP_CHROMIUM);
2172 DCHECK(resource->image_id); 1894 DCHECK(resource->image_id);
2173 } 1895 }
2174 1896
2175 void ResourceProvider::ReleaseImage(Resource* resource) { 1897 void ResourceProvider::ReleaseImage(ResourceId id) {
1898 Resource* resource = GetResource(id);
2176 DCHECK(resource->origin == Resource::Internal); 1899 DCHECK(resource->origin == Resource::Internal);
2177 DCHECK_EQ(resource->exported_count, 0); 1900 DCHECK_EQ(resource->exported_count, 0);
2178 1901
2179 if (!resource->image_id) 1902 if (!resource->image_id)
2180 return; 1903 return;
2181 1904
2182 GLES2Interface* gl = ContextGL(); 1905 GLES2Interface* gl = ContextGL();
2183 DCHECK(gl); 1906 DCHECK(gl);
2184 gl->DestroyImageCHROMIUM(resource->image_id); 1907 gl->DestroyImageCHROMIUM(resource->image_id);
2185 resource->image_id = 0; 1908 resource->image_id = 0;
2186 resource->bound_image_id = 0; 1909 resource->bound_image_id = 0;
2187 resource->dirty_image = false; 1910 resource->dirty_image = false;
2188 resource->allocated = false; 1911 resource->allocated = false;
2189 } 1912 }
2190 1913
2191 uint8_t* ResourceProvider::MapImage(const Resource* resource, int* stride) { 1914 uint8_t* ResourceProvider::MapImage(ResourceId id, int* stride) {
1915 Resource* resource = GetResource(id);
2192 DCHECK(ReadLockFenceHasPassed(resource)); 1916 DCHECK(ReadLockFenceHasPassed(resource));
2193 DCHECK(resource->origin == Resource::Internal); 1917 DCHECK(resource->origin == Resource::Internal);
2194 DCHECK_EQ(resource->exported_count, 0); 1918 DCHECK_EQ(resource->exported_count, 0);
1919 LockForWrite(id);
2195 1920
2196 if (resource->type == GLTexture) { 1921 if (resource->type == GLTexture) {
2197 DCHECK(resource->image_id); 1922 DCHECK(resource->image_id);
2198 GLES2Interface* gl = ContextGL(); 1923 GLES2Interface* gl = ContextGL();
2199 DCHECK(gl); 1924 DCHECK(gl);
2200 // MapImageCHROMIUM should be called prior to GetImageParameterivCHROMIUM. 1925 // MapImageCHROMIUM should be called prior to GetImageParameterivCHROMIUM.
2201 uint8_t* pixels = 1926 uint8_t* pixels =
2202 static_cast<uint8_t*>(gl->MapImageCHROMIUM(resource->image_id)); 1927 static_cast<uint8_t*>(gl->MapImageCHROMIUM(resource->image_id));
2203 gl->GetImageParameterivCHROMIUM( 1928 gl->GetImageParameterivCHROMIUM(
2204 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride); 1929 resource->image_id, GL_IMAGE_ROWBYTES_CHROMIUM, stride);
2205 return pixels; 1930 return pixels;
2206 } 1931 }
2207 DCHECK_EQ(Bitmap, resource->type); 1932 DCHECK_EQ(Bitmap, resource->type);
2208 *stride = 0; 1933 *stride = 0;
2209 return resource->pixels; 1934 return resource->pixels;
2210 } 1935 }
2211 1936
2212 void ResourceProvider::UnmapImage(const Resource* resource) { 1937 void ResourceProvider::UnmapImage(ResourceId id) {
1938 Resource* resource = GetResource(id);
2213 DCHECK(resource->origin == Resource::Internal); 1939 DCHECK(resource->origin == Resource::Internal);
2214 DCHECK_EQ(resource->exported_count, 0); 1940 DCHECK_EQ(resource->exported_count, 0);
1941 DCHECK(resource->locked_for_write);
2215 1942
2216 if (resource->image_id) { 1943 if (resource->image_id) {
2217 GLES2Interface* gl = ContextGL(); 1944 GLES2Interface* gl = ContextGL();
2218 DCHECK(gl); 1945 DCHECK(gl);
2219 gl->UnmapImageCHROMIUM(resource->image_id); 1946 gl->UnmapImageCHROMIUM(resource->image_id);
1947 resource->dirty_image = true;
2220 } 1948 }
1949
1950 UnlockForWrite(id);
1951 }
1952
1953 void ResourceProvider::AcquireSkSurface(ResourceId id) {
1954 Resource* resource = GetResource(id);
1955 DCHECK(resource->origin == Resource::Internal);
1956 DCHECK_EQ(resource->exported_count, 0);
1957
1958 if (resource->type != GLTexture)
1959 return;
1960
1961 if (resource->sk_surface)
1962 return;
1963
1964 class GrContext* gr_context = GrContext();
1965 // TODO(alokp): Implement TestContextProvider::GrContext().
1966 if (!gr_context)
1967 return;
1968
1969 LazyAllocate(resource);
1970
1971 GrBackendTextureDesc desc;
1972 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
1973 desc.fWidth = resource->size.width();
1974 desc.fHeight = resource->size.height();
1975 desc.fConfig = ToGrPixelConfig(resource->format);
1976 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
1977 desc.fTextureHandle = resource->gl_id;
1978 skia::RefPtr<GrTexture> gr_texture =
1979 skia::AdoptRef(gr_context->wrapBackendTexture(desc));
1980 SkSurface::TextRenderMode text_render_mode =
1981 use_distance_field_text_ ? SkSurface::kDistanceField_TextRenderMode
1982 : SkSurface::kStandard_TextRenderMode;
1983 resource->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect(
1984 gr_texture->asRenderTarget(), text_render_mode));
1985 }
1986
1987 void ResourceProvider::ReleaseSkSurface(ResourceId id) {
1988 Resource* resource = GetResource(id);
1989 DCHECK(resource->origin == Resource::Internal);
1990 DCHECK_EQ(resource->exported_count, 0);
1991
1992 resource->sk_surface.clear();
1993 }
1994
1995 SkSurface* ResourceProvider::LockForWriteToSkSurface(ResourceId id) {
1996 Resource* resource = GetResource(id);
1997 DCHECK(resource->origin == Resource::Internal);
1998 DCHECK_EQ(resource->exported_count, 0);
1999
2000 LockForWrite(id);
2001 return resource->sk_surface.get();
2002 }
2003
2004 void ResourceProvider::UnlockForWriteToSkSurface(ResourceId id) {
2005 UnlockForWrite(id);
2221 } 2006 }
2222 2007
2223 void ResourceProvider::CopyResource(ResourceId source_id, ResourceId dest_id) { 2008 void ResourceProvider::CopyResource(ResourceId source_id, ResourceId dest_id) {
2224 TRACE_EVENT0("cc", "ResourceProvider::CopyResource"); 2009 TRACE_EVENT0("cc", "ResourceProvider::CopyResource");
2225 2010
2226 Resource* source_resource = GetResource(source_id); 2011 Resource* source_resource = GetResource(source_id);
2227 DCHECK(!source_resource->lock_for_read_count); 2012 DCHECK(!source_resource->lock_for_read_count);
2228 DCHECK(source_resource->origin == Resource::Internal); 2013 DCHECK(source_resource->origin == Resource::Internal);
2229 DCHECK_EQ(source_resource->exported_count, 0); 2014 DCHECK_EQ(source_resource->exported_count, 0);
2230 DCHECK(source_resource->allocated); 2015 DCHECK(source_resource->allocated);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 ContextProvider* context_provider = output_surface_->context_provider(); 2086 ContextProvider* context_provider = output_surface_->context_provider();
2302 return context_provider ? context_provider->ContextGL() : NULL; 2087 return context_provider ? context_provider->ContextGL() : NULL;
2303 } 2088 }
2304 2089
2305 class GrContext* ResourceProvider::GrContext() const { 2090 class GrContext* ResourceProvider::GrContext() const {
2306 ContextProvider* context_provider = output_surface_->context_provider(); 2091 ContextProvider* context_provider = output_surface_->context_provider();
2307 return context_provider ? context_provider->GrContext() : NULL; 2092 return context_provider ? context_provider->GrContext() : NULL;
2308 } 2093 }
2309 2094
2310 } // namespace cc 2095 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698