Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: cc/test/fake_ui_resource_layer_tree_host_impl.cc

Issue 1062043003: cc: Add ResourceId validation checks at the time of AppendQuads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resource-validate: fixtests Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/test/fake_ui_resource_layer_tree_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/fake_ui_resource_layer_tree_host_impl.h" 5 #include "cc/test/fake_ui_resource_layer_tree_host_impl.h"
6 6
7 #include "cc/resources/ui_resource_bitmap.h" 7 #include "cc/resources/ui_resource_bitmap.h"
8 #include "cc/test/fake_layer_tree_host_impl.h" 8 #include "cc/test/fake_layer_tree_host_impl.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl( 12 FakeUIResourceLayerTreeHostImpl::FakeUIResourceLayerTreeHostImpl(
13 Proxy* proxy, 13 Proxy* proxy,
14 SharedBitmapManager* manager) 14 SharedBitmapManager* manager)
15 : FakeLayerTreeHostImpl(proxy, manager, nullptr), 15 : FakeLayerTreeHostImpl(proxy, manager, nullptr) {
16 fake_next_resource_id_(1) {
17 } 16 }
18 17
19 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {} 18 FakeUIResourceLayerTreeHostImpl::~FakeUIResourceLayerTreeHostImpl() {}
20 19
21 void FakeUIResourceLayerTreeHostImpl::CreateUIResource( 20 void FakeUIResourceLayerTreeHostImpl::CreateUIResource(
22 UIResourceId uid, 21 UIResourceId uid,
23 const UIResourceBitmap& bitmap) { 22 const UIResourceBitmap& bitmap) {
24 if (ResourceIdForUIResource(uid)) 23 if (ResourceIdForUIResource(uid))
25 DeleteUIResource(uid); 24 DeleteUIResource(uid);
26 25
27 UIResourceData data; 26 UIResourceData data;
28 data.resource_id = fake_next_resource_id_++; 27 data.resource_id = resource_provider()->CreateResource(
28 bitmap.GetSize(), GL_CLAMP_TO_EDGE,
29 ResourceProvider::TEXTURE_HINT_IMMUTABLE, RGBA_8888);
30
29 data.size = bitmap.GetSize(); 31 data.size = bitmap.GetSize();
30 data.opaque = bitmap.GetOpaque(); 32 data.opaque = bitmap.GetOpaque();
31 fake_ui_resource_map_[uid] = data; 33 fake_ui_resource_map_[uid] = data;
32 } 34 }
33 35
34 void FakeUIResourceLayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { 36 void FakeUIResourceLayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
35 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 37 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
36 if (id) 38 if (id)
37 fake_ui_resource_map_.erase(uid); 39 fake_ui_resource_map_.erase(uid);
38 } 40 }
39 41
40 ResourceProvider::ResourceId 42 ResourceProvider::ResourceId
41 FakeUIResourceLayerTreeHostImpl::ResourceIdForUIResource( 43 FakeUIResourceLayerTreeHostImpl::ResourceIdForUIResource(
42 UIResourceId uid) const { 44 UIResourceId uid) const {
43 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid); 45 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid);
44 if (iter != fake_ui_resource_map_.end()) 46 if (iter != fake_ui_resource_map_.end())
45 return iter->second.resource_id; 47 return iter->second.resource_id;
46 return 0; 48 return 0;
47 } 49 }
48 50
49 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid) 51 bool FakeUIResourceLayerTreeHostImpl::IsUIResourceOpaque(UIResourceId uid)
50 const { 52 const {
51 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid); 53 UIResourceMap::const_iterator iter = fake_ui_resource_map_.find(uid);
52 DCHECK(iter != fake_ui_resource_map_.end()); 54 DCHECK(iter != fake_ui_resource_map_.end());
53 return iter->second.opaque; 55 return iter->second.opaque;
54 } 56 }
55 57
56 } // namespace cc 58 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_ui_resource_layer_tree_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698