Chromium Code Reviews| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/numerics/safe_math.h" | 8 #include "base/numerics/safe_math.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | |
| 11 #include "base/strings/stringprintf.h" | |
| 10 | 12 |
| 11 namespace cc { | 13 namespace cc { |
| 12 | 14 |
| 13 SharedBitmap::SharedBitmap(uint8* pixels, const SharedBitmapId& id) | 15 SharedBitmap::SharedBitmap(uint8* pixels, const SharedBitmapId& id) |
| 14 : pixels_(pixels), id_(id) { | 16 : pixels_(pixels), id_(id) { |
| 15 } | 17 } |
| 16 | 18 |
| 17 SharedBitmap::~SharedBitmap() { | 19 SharedBitmap::~SharedBitmap() { |
| 18 } | 20 } |
| 19 | 21 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 } | 61 } |
| 60 | 62 |
| 61 // static | 63 // static |
| 62 SharedBitmapId SharedBitmap::GenerateId() { | 64 SharedBitmapId SharedBitmap::GenerateId() { |
| 63 SharedBitmapId id; | 65 SharedBitmapId id; |
| 64 // Needs cryptographically-secure random numbers. | 66 // Needs cryptographically-secure random numbers. |
| 65 base::RandBytes(id.name, sizeof(id.name)); | 67 base::RandBytes(id.name, sizeof(id.name)); |
| 66 return id; | 68 return id; |
| 67 } | 69 } |
| 68 | 70 |
| 71 base::trace_event::MemoryAllocatorDumpGuid GetSharedBitmapGUIDForTracing( | |
| 72 const SharedBitmapId& bitmap_id) { | |
| 73 auto bitmap_id_hex = base::HexEncode(bitmap_id.name, sizeof(bitmap_id.name)); | |
|
ssid
2015/07/29 11:17:43
Please add a line pmd->CreateSharedGlobalAllocato
ericrk
2015/07/29 18:46:46
We've currently been doing this at the call-site (
| |
| 74 return base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( | |
| 75 "gpumemorybuffer-x-process/%s", bitmap_id_hex.c_str())); | |
|
ericrk
2015/07/28 21:02:32
These IDs are globally unique already right? Share
reveman
2015/07/28 21:38:49
s/gpumemorybuffer-x-process/sharedbitmap-x-process
petrcermak
2015/07/29 16:13:34
Yest, the IDs are globally unique.
ericrk
2015/07/29 18:46:46
Done.
| |
| 76 } | |
| 77 | |
| 69 } // namespace cc | 78 } // namespace cc |
| OLD | NEW |