diff options
author | danakj <danakj@chromium.org> | 2015-02-18 18:41:05 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-19 02:41:36 +0000 |
commit | 8d86c9e54e34d7c4b75b6c94689ef28b1fe65dfb (patch) | |
tree | ff4d8cc39b33d0b273989269eb705e9a6132c407 /cc | |
parent | 2f7a8e80b83aa581aa6de86117a692093d16c217 (diff) | |
download | chromium_src-8d86c9e54e34d7c4b75b6c94689ef28b1fe65dfb.zip chromium_src-8d86c9e54e34d7c4b75b6c94689ef28b1fe65dfb.tar.gz chromium_src-8d86c9e54e34d7c4b75b6c94689ef28b1fe65dfb.tar.bz2 |
cc: Stop using TextureUploader for UIResources, HUD, and tests.
This adds a new simpler method to ResourceProvider called
CopyToResource and uses that instead. This removes TextureUploader
from the path of most impl-side painting code.
R=enne
BUG=454575
Review URL: https://codereview.chromium.org/938893002
Cr-Commit-Position: refs/heads/master@{#316978}
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.cc | 9 | ||||
-rw-r--r-- | cc/output/renderer_pixeltest.cc | 56 | ||||
-rw-r--r-- | cc/output/software_renderer_unittest.cc | 23 | ||||
-rw-r--r-- | cc/resources/resource_provider.cc | 48 | ||||
-rw-r--r-- | cc/resources/resource_provider.h | 4 | ||||
-rw-r--r-- | cc/resources/resource_provider_unittest.cc | 81 | ||||
-rw-r--r-- | cc/resources/texture_uploader.cc | 25 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 15 |
8 files changed, 136 insertions, 125 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index 97fddae..e71ea67 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -210,13 +210,10 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture( size_t row_bytes = 0; const void* pixels = hud_surface_->getCanvas()->peekPixels(&info, &row_bytes); DCHECK(pixels); - gfx::Rect content_rect(internal_content_bounds_); DCHECK(info.colorType() == kN32_SkColorType); - resource_provider->SetPixels(resources_.back()->id(), - static_cast<const uint8_t*>(pixels), - content_rect, - content_rect, - gfx::Vector2d()); + resource_provider->CopyToResource(resources_.back()->id(), + static_cast<const uint8_t*>(pixels), + internal_content_bounds_); } void HeadsUpDisplayLayerImpl::ReleaseResources() { diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc index 2754483..dc21b2d 100644 --- a/cc/output/renderer_pixeltest.cc +++ b/cc/output/renderer_pixeltest.cc @@ -124,19 +124,16 @@ void CreateTestTextureDrawQuad(const gfx::Rect& rect, SkColorGetR(texel_color), SkColorGetG(texel_color), SkColorGetB(texel_color)); - std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color); + size_t num_pixels = static_cast<size_t>(rect.width()) * rect.height(); + std::vector<uint32_t> pixels(num_pixels, pixel_color); ResourceProvider::ResourceId resource = resource_provider->CreateResource(rect.size(), GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, RGBA_8888); - resource_provider->SetPixels( - resource, - reinterpret_cast<uint8_t*>(&pixels.front()), - rect, - rect, - gfx::Vector2d()); + resource_provider->CopyToResource( + resource, reinterpret_cast<uint8_t*>(&pixels.front()), rect.size()); float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -1333,12 +1330,9 @@ TYPED_TEST(RendererPixelTest, RenderPassAndMaskWithPartialQuad) { RGBA_8888); { SkAutoLockPixels lock(bitmap); - this->resource_provider_->SetPixels( - mask_resource_id, - reinterpret_cast<uint8_t*>(bitmap.getPixels()), - mask_rect, - mask_rect, - gfx::Vector2d()); + this->resource_provider_->CopyToResource( + mask_resource_id, reinterpret_cast<uint8_t*>(bitmap.getPixels()), + mask_rect.size()); } // This RenderPassDrawQuad does not include the full |viewport_rect| which is @@ -2124,12 +2118,8 @@ TYPED_TEST(RendererPixelTest, TileDrawQuadNearestNeighbor) { { SkAutoLockPixels lock(bitmap); - this->resource_provider_->SetPixels( - resource, - static_cast<uint8_t*>(bitmap.getPixels()), - gfx::Rect(tile_size), - gfx::Rect(tile_size), - gfx::Vector2d()); + this->resource_provider_->CopyToResource( + resource, static_cast<uint8_t*>(bitmap.getPixels()), tile_size); } RenderPassId id(1, 1); @@ -2465,7 +2455,7 @@ TYPED_TEST(RendererPixelTest, WrapModeRepeat) { SharedQuadState* shared_state = CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); - gfx::Rect texture_rect(4, 4); + gfx::Size texture_size(4, 4); SkPMColor colors[4] = { SkPreMultiplyColor(SkColorSetARGB(255, 0, 255, 0)), SkPreMultiplyColor(SkColorSetARGB(255, 0, 128, 0)), @@ -2480,33 +2470,23 @@ TYPED_TEST(RendererPixelTest, WrapModeRepeat) { }; ResourceProvider::ResourceId resource = this->resource_provider_->CreateResource( - texture_rect.size(), - GL_REPEAT, - ResourceProvider::TextureHintImmutable, + texture_size, GL_REPEAT, ResourceProvider::TextureHintImmutable, RGBA_8888); - this->resource_provider_->SetPixels( - resource, - reinterpret_cast<uint8_t*>(pixels), - texture_rect, - texture_rect, - gfx::Vector2d()); + this->resource_provider_->CopyToResource( + resource, reinterpret_cast<uint8_t*>(pixels), texture_size); float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; TextureDrawQuad* texture_quad = pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); texture_quad->SetNew( - shared_state, - gfx::Rect(this->device_viewport_size_), - gfx::Rect(), - gfx::Rect(this->device_viewport_size_), - resource, + shared_state, gfx::Rect(this->device_viewport_size_), gfx::Rect(), + gfx::Rect(this->device_viewport_size_), resource, true, // premultiplied_alpha gfx::PointF(0.0f, 0.0f), // uv_top_left gfx::PointF( // uv_bottom_right - this->device_viewport_size_.width() / texture_rect.width(), - this->device_viewport_size_.height() / texture_rect.height()), - SK_ColorWHITE, - vertex_opacity, + this->device_viewport_size_.width() / texture_size.width(), + this->device_viewport_size_.height() / texture_size.height()), + SK_ColorWHITE, vertex_opacity, false, // flipped false); // nearest_neighbor diff --git a/cc/output/software_renderer_unittest.cc b/cc/output/software_renderer_unittest.cc index fa25200..28036bb 100644 --- a/cc/output/software_renderer_unittest.cc +++ b/cc/output/software_renderer_unittest.cc @@ -174,17 +174,11 @@ TEST_F(SoftwareRendererTest, TileQuad) { cyan_tile.allocN32Pixels(inner_size.width(), inner_size.height()); cyan_tile.eraseColor(SK_ColorCYAN); - resource_provider()->SetPixels( - resource_yellow, - static_cast<uint8_t*>(yellow_tile.getPixels()), - gfx::Rect(outer_size), - gfx::Rect(outer_size), - gfx::Vector2d()); - resource_provider()->SetPixels(resource_cyan, - static_cast<uint8_t*>(cyan_tile.getPixels()), - gfx::Rect(inner_size), - gfx::Rect(inner_size), - gfx::Vector2d()); + resource_provider()->CopyToResource( + resource_yellow, static_cast<uint8_t*>(yellow_tile.getPixels()), + outer_size); + resource_provider()->CopyToResource( + resource_cyan, static_cast<uint8_t*>(cyan_tile.getPixels()), inner_size); gfx::Rect root_rect = outer_rect; @@ -265,11 +259,8 @@ TEST_F(SoftwareRendererTest, TileQuadVisibleRect) { 0, visible_rect.bottom() - 1, tile_rect.width(), tile_rect.bottom()), SK_ColorYELLOW); - resource_provider()->SetPixels(resource_cyan, - static_cast<uint8_t*>(cyan_tile.getPixels()), - gfx::Rect(tile_size), - gfx::Rect(tile_size), - gfx::Vector2d()); + resource_provider()->CopyToResource( + resource_cyan, static_cast<uint8_t*>(cyan_tile.getPixels()), tile_size); gfx::Rect root_rect(tile_size); diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 42ef4b3..b04708a 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -780,6 +780,54 @@ void ResourceProvider::SetPixels(ResourceId id, } } +void ResourceProvider::CopyToResource(ResourceId id, + const uint8_t* image, + const gfx::Size& image_size) { + Resource* resource = GetResource(id); + DCHECK(!resource->locked_for_write); + DCHECK(!resource->lock_for_read_count); + DCHECK(resource->origin == Resource::Internal); + DCHECK_EQ(resource->exported_count, 0); + DCHECK(ReadLockFenceHasPassed(resource)); + LazyAllocate(resource); + + DCHECK_EQ(image_size.width(), resource->size.width()); + DCHECK_EQ(image_size.height(), resource->size.height()); + + if (resource->type == Bitmap) { + DCHECK_EQ(Bitmap, resource->type); + DCHECK(resource->allocated); + DCHECK_EQ(RGBA_8888, resource->format); + SkImageInfo source_info = + SkImageInfo::MakeN32Premul(image_size.width(), image_size.height()); + size_t image_stride = image_size.width() * 4; + + ScopedWriteLockSoftware lock(this, id); + SkCanvas dest(lock.sk_bitmap()); + dest.writePixels(source_info, image, image_stride, 0, 0); + } else { + DCHECK(resource->gl_id); + DCHECK(!resource->pending_set_pixels); + DCHECK_EQ(resource->target, static_cast<GLenum>(GL_TEXTURE_2D)); + GLES2Interface* gl = ContextGL(); + DCHECK(gl); + DCHECK(texture_uploader_.get()); + gl->BindTexture(GL_TEXTURE_2D, resource->gl_id); + + if (resource->format == ETC1) { + size_t num_bytes = static_cast<size_t>(image_size.width()) * + image_size.height() * BitsPerPixel(ETC1) / 8; + gl->CompressedTexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(ETC1), + image_size.width(), image_size.height(), 0, + num_bytes, image); + } else { + gl->TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_size.width(), + image_size.height(), GLDataFormat(resource->format), + GLDataType(resource->format), image); + } + } +} + size_t ResourceProvider::NumBlockingUploads() { if (!texture_uploader_) return 0; diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h index 167ef20..6315140 100644 --- a/cc/resources/resource_provider.h +++ b/cc/resources/resource_provider.h @@ -150,11 +150,15 @@ class CC_EXPORT ResourceProvider { // Update pixels from image, copying source_rect (in image) to dest_offset (in // the resource). + // NOTE: DEPRECATED. Use CopyToResource() instead. void SetPixels(ResourceId id, const uint8_t* image, const gfx::Rect& image_rect, const gfx::Rect& source_rect, const gfx::Vector2d& dest_offset); + void CopyToResource(ResourceId id, + const uint8_t* image, + const gfx::Size& image_size); // Check upload status. size_t NumBlockingUploads(); diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc index 2bba801..7717894 100644 --- a/cc/resources/resource_provider_unittest.cc +++ b/cc/resources/resource_provider_unittest.cc @@ -522,8 +522,7 @@ void CheckCreateResource(ResourceProvider::ResourceType expected_default_type, EXPECT_EQ(0u, context->NumTextures()); uint8_t data[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); - resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); + resource_provider->CopyToResource(id, data, size); if (expected_default_type == ResourceProvider::GLTexture) EXPECT_EQ(1u, context->NumTextures()); @@ -608,6 +607,38 @@ TEST_P(ResourceProviderTest, Upload) { resource_provider_->DeleteResource(id); } +TEST_P(ResourceProviderTest, SimpleUpload) { + gfx::Size size(2, 2); + ResourceFormat format = RGBA_8888; + size_t pixel_size = TextureSizeBytes(size, format); + ASSERT_EQ(16U, pixel_size); + + ResourceProvider::ResourceId id = resource_provider_->CreateResource( + size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); + + uint8_t image[16] = {0}; + resource_provider_->CopyToResource(id, image, size); + { + uint8_t result[16] = {0}; + uint8_t expected[16] = {0}; + GetResourcePixels(resource_provider_.get(), context(), id, size, format, + result); + EXPECT_EQ(0, memcmp(expected, result, pixel_size)); + } + + for (uint8_t i = 0; i < pixel_size; ++i) + image[i] = i; + resource_provider_->CopyToResource(id, image, size); + { + uint8_t result[16] = {0}; + uint8_t expected[16] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; + GetResourcePixels(resource_provider_.get(), context(), id, size, format, + result); + EXPECT_EQ(0, memcmp(expected, result, pixel_size)); + } +} + TEST_P(ResourceProviderTest, TransferGLResources) { if (GetParam() != ResourceProvider::GLTexture) return; @@ -619,13 +650,12 @@ TEST_P(ResourceProviderTest, TransferGLResources) { ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id1, data1, size); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = { 5, 5, 5, 5 }; - child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id2, data2, size); ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); @@ -863,8 +893,7 @@ TEST_P(ResourceProviderTest, ReadLockCountStopsReturnToChildOrDelete) { ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = {1, 2, 3, 4}; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id1, data1, size); ReturnedResourceArray returned_to_child; int child_id = @@ -969,13 +998,12 @@ TEST_P(ResourceProviderTest, TransferSoftwareResources) { ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id1, data1, size); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = { 5, 5, 5, 5 }; - child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id2, data2, size); scoped_ptr<SharedBitmap> shared_bitmap(CreateAndFillSharedBitmap( shared_bitmap_manager_.get(), gfx::Size(1, 1), 0)); @@ -1171,8 +1199,7 @@ TEST_P(ResourceProviderTest, TransferGLToSoftware) { ResourceProvider::ResourceId id1 = child_resource_provider->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); - child_resource_provider->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); + child_resource_provider->CopyToResource(id1, data1, size); ReturnedResourceArray returned_to_child; int child_id = @@ -1218,8 +1245,7 @@ TEST_P(ResourceProviderTest, TransferInvalidSoftware) { ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id1, data1, size); ReturnedResourceArray returned_to_child; int child_id = @@ -1266,13 +1292,12 @@ TEST_P(ResourceProviderTest, DeleteExportedResources) { ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id1, data1, size); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = {5, 5, 5, 5}; - child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id2, data2, size); ReturnedResourceArray returned_to_child; int child_id = @@ -1360,13 +1385,12 @@ TEST_P(ResourceProviderTest, DestroyChildWithExportedResources) { ResourceProvider::ResourceId id1 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data1[4] = {1, 2, 3, 4}; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id1, data1, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id1, data1, size); ResourceProvider::ResourceId id2 = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data2[4] = {5, 5, 5, 5}; - child_resource_provider_->SetPixels(id2, data2, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id2, data2, size); ReturnedResourceArray returned_to_child; int child_id = @@ -1471,8 +1495,7 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources) { ResourceProvider::ResourceId id = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id, data, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id, data, size); ReturnedResourceArray returned_to_child; int child_id = @@ -1521,8 +1544,7 @@ TEST_P(ResourceProviderTest, UnuseTransferredResources) { ResourceProvider::ResourceId id = child_resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format); uint8_t data[4] = {1, 2, 3, 4}; - gfx::Rect rect(size); - child_resource_provider_->SetPixels(id, data, rect, rect, gfx::Vector2d()); + child_resource_provider_->CopyToResource(id, data, size); ReturnedResourceArray returned_to_child; int child_id = @@ -1695,10 +1717,9 @@ class ResourceProviderTestTextureFilters : public ResourceProviderTest { Mock::VerifyAndClearExpectations(child_context); uint8_t data[4] = { 1, 2, 3, 4 }; - gfx::Rect rect(size); EXPECT_CALL(*child_context, bindTexture(GL_TEXTURE_2D, child_texture_id)); - child_resource_provider->SetPixels(id, data, rect, rect, gfx::Vector2d()); + child_resource_provider->CopyToResource(id, data, size); Mock::VerifyAndClearExpectations(child_context); // The texture is set to |child_filter| in the child. @@ -3035,7 +3056,6 @@ TEST_P(ResourceProviderTest, TextureAllocation) { gfx::Size size(2, 2); gfx::Vector2d offset(0, 0); - gfx::Rect rect(0, 0, 2, 2); ResourceFormat format = RGBA_8888; ResourceProvider::ResourceId id = 0; uint8_t pixels[16] = { 0 }; @@ -3062,7 +3082,7 @@ TEST_P(ResourceProviderTest, TextureAllocation) { EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3); EXPECT_CALL(*context, texImage2D(_, _, _, 2, 2, _, _, _, _)).Times(1); EXPECT_CALL(*context, texSubImage2D(_, _, _, _, 2, 2, _, _, _)).Times(1); - resource_provider->SetPixels(id, pixels, rect, rect, offset); + resource_provider->CopyToResource(id, pixels, size); EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); resource_provider->DeleteResource(id); @@ -3595,7 +3615,7 @@ TEST_P(ResourceProviderTest, CompressedTextureETC1Allocate) { resource_provider->DeleteResource(id); } -TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) { +TEST_P(ResourceProviderTest, CompressedTextureETC1Upload) { if (GetParam() != ResourceProvider::GLTexture) return; @@ -3629,8 +3649,7 @@ TEST_P(ResourceProviderTest, CompressedTextureETC1SetPixels) { EXPECT_CALL(*context, compressedTexImage2D( _, 0, _, size.width(), size.height(), _, _, _)).Times(1); - resource_provider->SetPixels( - id, pixels, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(0, 0)); + resource_provider->CopyToResource(id, pixels, size); EXPECT_CALL(*context, RetireTextureId(texture_id)).Times(1); resource_provider->DeleteResource(id); diff --git a/cc/resources/texture_uploader.cc b/cc/resources/texture_uploader.cc index 3d0f681..601fa8f 100644 --- a/cc/resources/texture_uploader.cc +++ b/cc/resources/texture_uploader.cc @@ -146,14 +146,7 @@ void TextureUploader::Upload(const uint8* image, if (is_full_upload) BeginQuery(); - if (format == ETC1) { - // ETC1 does not support subimage uploads. - DCHECK(is_full_upload); - UploadWithTexImageETC1(image, size); - } else { - UploadWithMapTexSubImage( - image, image_rect, source_rect, dest_offset, format); - } + UploadWithMapTexSubImage(image, image_rect, source_rect, dest_offset, format); if (is_full_upload) EndQuery(); @@ -291,22 +284,6 @@ void TextureUploader::UploadWithMapTexSubImage(const uint8* image, gl_->UnmapTexSubImage2DCHROMIUM(pixel_dest); } -void TextureUploader::UploadWithTexImageETC1(const uint8* image, - const gfx::Size& size) { - TRACE_EVENT0("cc", "TextureUploader::UploadWithTexImageETC1"); - DCHECK_EQ(0, size.width() % 4); - DCHECK_EQ(0, size.height() % 4); - - gl_->CompressedTexImage2D(GL_TEXTURE_2D, - 0, - GLInternalFormat(ETC1), - size.width(), - size.height(), - 0, - Resource::MemorySizeBytes(size, ETC1), - image); -} - void TextureUploader::ProcessQueries() { while (!pending_queries_.empty()) { if (pending_queries_.front()->IsPending()) diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 70dc582..ebd8990 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -3384,11 +3384,9 @@ void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, format = ETC1; break; } - id = - resource_provider_->CreateResource(bitmap.GetSize(), - wrap_mode, - ResourceProvider::TextureHintImmutable, - format); + id = resource_provider_->CreateResource( + bitmap.GetSize(), wrap_mode, ResourceProvider::TextureHintImmutable, + format); UIResourceData data; data.resource_id = id; @@ -3398,11 +3396,8 @@ void LayerTreeHostImpl::CreateUIResource(UIResourceId uid, ui_resource_map_[uid] = data; AutoLockUIResourceBitmap bitmap_lock(bitmap); - resource_provider_->SetPixels(id, - bitmap_lock.GetPixels(), - gfx::Rect(bitmap.GetSize()), - gfx::Rect(bitmap.GetSize()), - gfx::Vector2d(0, 0)); + resource_provider_->CopyToResource(id, bitmap_lock.GetPixels(), + bitmap.GetSize()); MarkUIResourceNotEvicted(uid); } |