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

Unified Diff: cc/resources/resource_provider.cc

Issue 938893002: cc: Stop using TextureUploader for UIResources, HUD, and tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: uiresource: etc1 Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 42ef4b389e3e24bbdda084df4cad5e9f850a10d9..b04708a74ecc745efcacdabe6c6394693eec11aa 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;
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698