aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrResourceKey.h
diff options
context:
space:
mode:
authorGravatar kkinnunen <kkinnunen@nvidia.com>2015-01-21 06:39:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-21 06:39:14 -0800
commit711ef4831363fb8cbdf061dc2c36c65b13c0ccf2 (patch)
tree71617221284467dd0cc91c5da158e3d5d5e540ca /include/gpu/GrResourceKey.h
parent034e94877b7e63033d9ae5435d8e3e45977921bc (diff)
Make GrScratchKey memory buffer correct size on copy
Scratch key memory buffer of a copy of a key was too big. The (new) copy was N times uint32_t bytes instead of N bytes. Adds few tests to resource cache. These tests would not catch the too big buffer. This is just a precaution for too small buffers. The main idea of the test change is that the scratch key should contain some information, so that lookup with a scratch key can also return no match. Otherwise testing of scratch lookup result is not indicative of correct code (eg. no-information scratch key will always match). Review URL: https://codereview.chromium.org/860333002
Diffstat (limited to 'include/gpu/GrResourceKey.h')
-rw-r--r--include/gpu/GrResourceKey.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/gpu/GrResourceKey.h b/include/gpu/GrResourceKey.h
index f662ed5511..43c6ff1770 100644
--- a/include/gpu/GrResourceKey.h
+++ b/include/gpu/GrResourceKey.h
@@ -46,9 +46,9 @@ public:
const uint32_t* data() const { return &fKey[kMetaDataCnt]; }
GrScratchKey& operator=(const GrScratchKey& that) {
- size_t size = that.size();
- fKey.reset(SkToInt(size));
- memcpy(fKey.get(), that.fKey.get(), size);
+ size_t bytes = that.size();
+ fKey.reset(SkToInt(bytes / sizeof(uint32_t)));
+ memcpy(fKey.get(), that.fKey.get(), bytes);
return *this;
}