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

Side by Side Diff: ui/base/resource/data_pack.h

Issue 10151025: Add scale factor tag to data packs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/test/test_content_client.cc ('k') | ui/base/resource/data_pack.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // DataPack represents a read-only view onto an on-disk file that contains 5 // DataPack represents a read-only view onto an on-disk file that contains
6 // (key, value) pairs of data. It's used to store static resources like 6 // (key, value) pairs of data. It's used to store static resources like
7 // translation strings and images. 7 // translation strings and images.
8 8
9 #ifndef UI_BASE_RESOURCE_DATA_PACK_H_ 9 #ifndef UI_BASE_RESOURCE_DATA_PACK_H_
10 #define UI_BASE_RESOURCE_DATA_PACK_H_ 10 #define UI_BASE_RESOURCE_DATA_PACK_H_
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 namespace file_util { 27 namespace file_util {
28 class MemoryMappedFile; 28 class MemoryMappedFile;
29 } 29 }
30 30
31 namespace ui { 31 namespace ui {
32 32
33 class UI_EXPORT DataPack : public ResourceHandle { 33 class UI_EXPORT DataPack : public ResourceHandle {
34 public: 34 public:
35 DataPack(); 35 DataPack(float scale_factor);
36 virtual ~DataPack(); 36 virtual ~DataPack();
37 37
38 // Load a pack file from |path|, returning false on error. 38 // Load a pack file from |path|, returning false on error.
39 bool Load(const FilePath& path); 39 bool Load(const FilePath& path);
40 40
41 // Writes a pack file containing |resources| to |path|. If there are any 41 // Writes a pack file containing |resources| to |path|. If there are any
42 // text resources to be written, their encoding must already agree to the 42 // text resources to be written, their encoding must already agree to the
43 // |textEncodingType| specified. If no text resources are present, please 43 // |textEncodingType| specified. If no text resources are present, please
44 // indicate BINARY. 44 // indicate BINARY.
45 static bool WritePack(const FilePath& path, 45 static bool WritePack(const FilePath& path,
46 const std::map<uint16, base::StringPiece>& resources, 46 const std::map<uint16, base::StringPiece>& resources,
47 TextEncodingType textEncodingType); 47 TextEncodingType textEncodingType);
48 48
49 // ResourceHandle implementation: 49 // ResourceHandle implementation:
50 virtual bool GetStringPiece(uint16 resource_id, 50 virtual bool GetStringPiece(uint16 resource_id,
51 base::StringPiece* data) const OVERRIDE; 51 base::StringPiece* data) const OVERRIDE;
52 virtual base::RefCountedStaticMemory* GetStaticMemory( 52 virtual base::RefCountedStaticMemory* GetStaticMemory(
53 uint16 resource_id) const OVERRIDE; 53 uint16 resource_id) const OVERRIDE;
54 virtual TextEncodingType GetTextEncodingType() const OVERRIDE; 54 virtual TextEncodingType GetTextEncodingType() const OVERRIDE;
55 virtual float GetScaleFactor() const OVERRIDE;
55 56
56 private: 57 private:
57 // The memory-mapped data. 58 // The memory-mapped data.
58 scoped_ptr<file_util::MemoryMappedFile> mmap_; 59 scoped_ptr<file_util::MemoryMappedFile> mmap_;
59 60
60 // Number of resources in the data. 61 // Number of resources in the data.
61 size_t resource_count_; 62 size_t resource_count_;
62 63
63 // Type of encoding for text resources. 64 // Type of encoding for text resources.
64 TextEncodingType text_encoding_type_; 65 TextEncodingType text_encoding_type_;
65 66
67 // The scale of the image in this resource pack relative to images in the 1x
68 // resource pak.
69 float scale_factor_;
70
66 DISALLOW_COPY_AND_ASSIGN(DataPack); 71 DISALLOW_COPY_AND_ASSIGN(DataPack);
67 }; 72 };
68 73
69 } // namespace ui 74 } // namespace ui
70 75
71 #endif // UI_BASE_RESOURCE_DATA_PACK_H_ 76 #endif // UI_BASE_RESOURCE_DATA_PACK_H_
OLDNEW
« no previous file with comments | « content/test/test_content_client.cc ('k') | ui/base/resource/data_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698