| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shared_bitmap.h" | 5 #include "cc/resources/shared_bitmap.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/shared_memory_handle.h" |
| 11 #include "base/numerics/safe_math.h" | 12 #include "base/numerics/safe_math.h" |
| 12 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 | 16 |
| 16 namespace cc { | 17 namespace cc { |
| 17 | 18 |
| 18 SharedBitmap::SharedBitmap(uint8_t* pixels, const SharedBitmapId& id) | 19 SharedBitmap::SharedBitmap(uint8_t* pixels, const SharedBitmapId& id) |
| 19 : pixels_(pixels), id_(id) {} | 20 : pixels_(pixels), id_(id) {} |
| 20 | 21 |
| 21 SharedBitmap::~SharedBitmap() { | 22 SharedBitmap::~SharedBitmap() { |
| 22 } | 23 } |
| 23 | 24 |
| 25 base::SharedMemoryHandle SharedBitmap::shared_memory_handle() const { |
| 26 return base::SharedMemoryHandle(); |
| 27 } |
| 28 |
| 24 // static | 29 // static |
| 25 bool SharedBitmap::SizeInBytes(const gfx::Size& size, size_t* size_in_bytes) { | 30 bool SharedBitmap::SizeInBytes(const gfx::Size& size, size_t* size_in_bytes) { |
| 26 if (size.IsEmpty()) | 31 if (size.IsEmpty()) |
| 27 return false; | 32 return false; |
| 28 base::CheckedNumeric<size_t> s = 4; | 33 base::CheckedNumeric<size_t> s = 4; |
| 29 s *= size.width(); | 34 s *= size.width(); |
| 30 s *= size.height(); | 35 s *= size.height(); |
| 31 if (!s.IsValid()) | 36 if (!s.IsValid()) |
| 32 return false; | 37 return false; |
| 33 *size_in_bytes = s.ValueOrDie(); | 38 *size_in_bytes = s.ValueOrDie(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 76 } |
| 72 | 77 |
| 73 base::trace_event::MemoryAllocatorDumpGuid GetSharedBitmapGUIDForTracing( | 78 base::trace_event::MemoryAllocatorDumpGuid GetSharedBitmapGUIDForTracing( |
| 74 const SharedBitmapId& bitmap_id) { | 79 const SharedBitmapId& bitmap_id) { |
| 75 auto bitmap_id_hex = base::HexEncode(bitmap_id.name, sizeof(bitmap_id.name)); | 80 auto bitmap_id_hex = base::HexEncode(bitmap_id.name, sizeof(bitmap_id.name)); |
| 76 return base::trace_event::MemoryAllocatorDumpGuid( | 81 return base::trace_event::MemoryAllocatorDumpGuid( |
| 77 base::StringPrintf("sharedbitmap-x-process/%s", bitmap_id_hex.c_str())); | 82 base::StringPrintf("sharedbitmap-x-process/%s", bitmap_id_hex.c_str())); |
| 78 } | 83 } |
| 79 | 84 |
| 80 } // namespace cc | 85 } // namespace cc |
| OLD | NEW |