| 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/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 ResourceId resource_id) | 1155 ResourceId resource_id) |
| 1156 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1156 : resource_provider_(resource_provider), resource_id_(resource_id) { |
| 1157 const Resource* resource = resource_provider->LockForRead(resource_id); | 1157 const Resource* resource = resource_provider->LockForRead(resource_id); |
| 1158 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource); | 1158 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap_, resource); |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware() { | 1161 ResourceProvider::ScopedReadLockSoftware::~ScopedReadLockSoftware() { |
| 1162 resource_provider_->UnlockForRead(resource_id_); | 1162 resource_provider_->UnlockForRead(resource_id_); |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 ResourceProvider::ScopedReadLockSkImage::ScopedReadLockSkImage( |
| 1166 ResourceProvider* resource_provider, |
| 1167 ResourceId resource_id) |
| 1168 : resource_provider_(resource_provider), resource_id_(resource_id) { |
| 1169 const Resource* resource = resource_provider->LockForRead(resource_id); |
| 1170 if (resource->gl_id) { |
| 1171 GrGLTextureInfo texture_info; |
| 1172 texture_info.fID = resource->gl_id; |
| 1173 texture_info.fTarget = resource->target; |
| 1174 GrBackendTextureDesc desc; |
| 1175 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 1176 desc.fWidth = resource->size.width(); |
| 1177 desc.fHeight = resource->size.height(); |
| 1178 desc.fConfig = ToGrPixelConfig(resource->format); |
| 1179 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 1180 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); |
| 1181 sk_image_ = SkImage::MakeFromTexture( |
| 1182 resource_provider->compositor_context_provider_->GrContext(), desc); |
| 1183 } else if (resource->pixels) { |
| 1184 SkBitmap sk_bitmap; |
| 1185 ResourceProvider::PopulateSkBitmapWithResource(&sk_bitmap, resource); |
| 1186 sk_bitmap.setImmutable(); |
| 1187 sk_image_ = SkImage::MakeFromBitmap(sk_bitmap); |
| 1188 } else { |
| 1189 NOTREACHED() << "Image not valid"; |
| 1190 } |
| 1191 } |
| 1192 |
| 1193 ResourceProvider::ScopedReadLockSkImage::~ScopedReadLockSkImage() { |
| 1194 resource_provider_->UnlockForRead(resource_id_); |
| 1195 } |
| 1196 |
| 1165 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware( | 1197 ResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware( |
| 1166 ResourceProvider* resource_provider, | 1198 ResourceProvider* resource_provider, |
| 1167 ResourceId resource_id) | 1199 ResourceId resource_id) |
| 1168 : resource_provider_(resource_provider), resource_id_(resource_id) { | 1200 : resource_provider_(resource_provider), resource_id_(resource_id) { |
| 1169 ResourceProvider::PopulateSkBitmapWithResource( | 1201 ResourceProvider::PopulateSkBitmapWithResource( |
| 1170 &sk_bitmap_, resource_provider->LockForWrite(resource_id)); | 1202 &sk_bitmap_, resource_provider->LockForWrite(resource_id)); |
| 1171 DCHECK(valid()); | 1203 DCHECK(valid()); |
| 1172 } | 1204 } |
| 1173 | 1205 |
| 1174 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { | 1206 ResourceProvider::ScopedWriteLockSoftware::~ScopedWriteLockSoftware() { |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 | 1977 |
| 1946 const int kImportance = 2; | 1978 const int kImportance = 2; |
| 1947 pmd->CreateSharedGlobalAllocatorDump(guid); | 1979 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 1948 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1980 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 1949 } | 1981 } |
| 1950 | 1982 |
| 1951 return true; | 1983 return true; |
| 1952 } | 1984 } |
| 1953 | 1985 |
| 1954 } // namespace cc | 1986 } // namespace cc |
| OLD | NEW |