OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <objidl.h> | 9 #include <objidl.h> |
10 #include <mlang.h> | 10 #include <mlang.h> |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // to reduce the width as well to make the size reduction more "balanced", but | 278 // to reduce the width as well to make the size reduction more "balanced", but |
279 // it rarely comes up in practice. | 279 // it rarely comes up in practice. |
280 if ((max_size != 0) && (height * stride > max_size)) | 280 if ((max_size != 0) && (height * stride > max_size)) |
281 height = max_size / stride; | 281 height = max_size / stride; |
282 | 282 |
283 const size_t size = height * stride; | 283 const size_t size = height * stride; |
284 | 284 |
285 if (!GetTransportDIBFromCache(memory, size)) { | 285 if (!GetTransportDIBFromCache(memory, size)) { |
286 *memory = CreateTransportDIB(size); | 286 *memory = CreateTransportDIB(size); |
287 if (!*memory) | 287 if (!*memory) |
288 return false; | 288 return NULL; |
289 } | 289 } |
290 | 290 |
291 return (*memory)->GetPlatformCanvas(width, height); | 291 return (*memory)->GetPlatformCanvas(width, height); |
292 } | 292 } |
293 | 293 |
294 void RenderProcessImpl::ReleaseTransportDIB(TransportDIB* mem) { | 294 void RenderProcessImpl::ReleaseTransportDIB(TransportDIB* mem) { |
295 if (PutSharedMemInCache(mem)) { | 295 if (PutSharedMemInCache(mem)) { |
296 shared_mem_cache_cleaner_.Reset(); | 296 shared_mem_cache_cleaner_.Reset(); |
297 return; | 297 return; |
298 } | 298 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 361 } |
362 | 362 |
363 void RenderProcessImpl::ClearTransportDIBCache() { | 363 void RenderProcessImpl::ClearTransportDIBCache() { |
364 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { | 364 for (size_t i = 0; i < arraysize(shared_mem_cache_); ++i) { |
365 if (shared_mem_cache_[i]) { | 365 if (shared_mem_cache_[i]) { |
366 FreeTransportDIB(shared_mem_cache_[i]); | 366 FreeTransportDIB(shared_mem_cache_[i]); |
367 shared_mem_cache_[i] = NULL; | 367 shared_mem_cache_[i] = NULL; |
368 } | 368 } |
369 } | 369 } |
370 } | 370 } |
OLD | NEW |