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

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

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 DCHECK(source_rect.y() >= image_rect.y()); 787 DCHECK(source_rect.y() >= image_rect.y());
788 DCHECK(source_rect.right() <= image_rect.right()); 788 DCHECK(source_rect.right() <= image_rect.right());
789 DCHECK(source_rect.bottom() <= image_rect.bottom()); 789 DCHECK(source_rect.bottom() <= image_rect.bottom());
790 SkImageInfo source_info = 790 SkImageInfo source_info =
791 SkImageInfo::MakeN32Premul(source_rect.width(), source_rect.height()); 791 SkImageInfo::MakeN32Premul(source_rect.width(), source_rect.height());
792 size_t image_row_bytes = image_rect.width() * 4; 792 size_t image_row_bytes = image_rect.width() * 4;
793 gfx::Vector2d source_offset = source_rect.origin() - image_rect.origin(); 793 gfx::Vector2d source_offset = source_rect.origin() - image_rect.origin();
794 image += source_offset.y() * image_row_bytes + source_offset.x() * 4; 794 image += source_offset.y() * image_row_bytes + source_offset.x() * 4;
795 795
796 ScopedWriteLockSoftware lock(this, id); 796 ScopedWriteLockSoftware lock(this, id);
797 SkCanvas* dest = lock.sk_canvas(); 797 SkCanvas dest(lock.sk_bitmap());
798 dest->writePixels( 798 dest.writePixels(source_info, image, image_row_bytes, dest_offset.x(),
799 source_info, image, image_row_bytes, dest_offset.x(), dest_offset.y()); 799 dest_offset.y());
800 } 800 }
801 } 801 }
802 802
803 size_t ResourceProvider::NumBlockingUploads() { 803 size_t ResourceProvider::NumBlockingUploads() {
804 if (!texture_uploader_) 804 if (!texture_uploader_)
805 return 0; 805 return 0;
806 806
807 return texture_uploader_->NumBlockingUploads(); 807 return texture_uploader_->NumBlockingUploads();
808 } 808 }
809 809
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 resource_provider_->UnlockForRead(resource_id_); 1031 resource_provider_->UnlockForRead(resource_id_);
1032 } 1032 }
1033 1033
1034 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware( 1034 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware(
1035 ResourceProvider* resource_provider, 1035 ResourceProvider* resource_provider,
1036 ResourceProvider::ResourceId resource_id) 1036 ResourceProvider::ResourceId resource_id)
1037 : resource_provider_(resource_provider), 1037 : resource_provider_(resource_provider),
1038 resource_(resource_provider->LockForWrite(resource_id)) { 1038 resource_(resource_provider->LockForWrite(resource_id)) {
1039 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource_); 1039 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource_);
1040 DCHECK(valid()); 1040 DCHECK(valid());
1041 sk_canvas_.reset(new SkCanvas(sk_bitmap_));
1042 } 1041 }
1043 1042
1044 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { 1043 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() {
1045 DCHECK(thread_checker_.CalledOnValidThread()); 1044 DCHECK(thread_checker_.CalledOnValidThread());
1046 resource_provider_->UnlockForWrite(resource_); 1045 resource_provider_->UnlockForWrite(resource_);
1047 } 1046 }
1048 1047
1049 ResourceProvider::ScopedWriteLockGpuMemoryBuffer:: 1048 ResourceProvider::ScopedWriteLockGpuMemoryBuffer::
1050 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider, 1049 ScopedWriteLockGpuMemoryBuffer(ResourceProvider* resource_provider,
1051 ResourceProvider::ResourceId resource_id) 1050 ResourceProvider::ResourceId resource_id)
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 DCHECK_EQ(GLTexture, source_resource->type); 2069 DCHECK_EQ(GLTexture, source_resource->type);
2071 DCHECK(source_resource->allocated); 2070 DCHECK(source_resource->allocated);
2072 LazyCreate(source_resource); 2071 LazyCreate(source_resource);
2073 2072
2074 Resource* dest_resource = GetResource(dest_id); 2073 Resource* dest_resource = GetResource(dest_id);
2075 DCHECK(!dest_resource->locked_for_write); 2074 DCHECK(!dest_resource->locked_for_write);
2076 DCHECK(!dest_resource->lock_for_read_count); 2075 DCHECK(!dest_resource->lock_for_read_count);
2077 DCHECK(dest_resource->origin == Resource::Internal); 2076 DCHECK(dest_resource->origin == Resource::Internal);
2078 DCHECK_EQ(dest_resource->exported_count, 0); 2077 DCHECK_EQ(dest_resource->exported_count, 0);
2079 DCHECK_EQ(GLTexture, dest_resource->type); 2078 DCHECK_EQ(GLTexture, dest_resource->type);
2080 LazyCreate(dest_resource); 2079 LazyAllocate(dest_resource);
2081 2080
2082 DCHECK_EQ(source_resource->type, dest_resource->type); 2081 DCHECK_EQ(source_resource->type, dest_resource->type);
2083 DCHECK_EQ(source_resource->format, dest_resource->format); 2082 DCHECK_EQ(source_resource->format, dest_resource->format);
2084 DCHECK(source_resource->size == dest_resource->size); 2083 DCHECK(source_resource->size == dest_resource->size);
2085 2084
2086 GLES2Interface* gl = ContextGL(); 2085 GLES2Interface* gl = ContextGL();
2087 DCHECK(gl); 2086 DCHECK(gl);
2088 if (source_resource->image_id && source_resource->dirty_image) { 2087 if (source_resource->image_id && source_resource->dirty_image) {
2089 gl->BindTexture(source_resource->target, source_resource->gl_id); 2088 gl->BindTexture(source_resource->target, source_resource->gl_id);
2090 BindImageForSampling(source_resource); 2089 BindImageForSampling(source_resource);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 ContextProvider* context_provider = output_surface_->context_provider(); 2154 ContextProvider* context_provider = output_surface_->context_provider();
2156 return context_provider ? context_provider->ContextGL() : NULL; 2155 return context_provider ? context_provider->ContextGL() : NULL;
2157 } 2156 }
2158 2157
2159 class GrContext* ResourceProvider::GrContext() const { 2158 class GrContext* ResourceProvider::GrContext() const {
2160 ContextProvider* context_provider = output_surface_->context_provider(); 2159 ContextProvider* context_provider = output_surface_->context_provider();
2161 return context_provider ? context_provider->GrContext() : NULL; 2160 return context_provider ? context_provider->GrContext() : NULL;
2162 } 2161 }
2163 2162
2164 } // namespace cc 2163 } // namespace cc
OLDNEW
« 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