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

Side by Side Diff: runtime/embedders/openglui/common/sample.h

Issue 11883013: Refactored OpenGL embedder that works on Android, Mac or Linux. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef EMBEDDERS_OPENGLUI_COMMON_SAMPLE_H_
6 #define EMBEDDERS_OPENGLUI_COMMON_SAMPLE_H_
7
8 #include "embedders/openglui/common/resource.h"
9
10 class Sample {
11 public:
12 explicit Sample(const char* path)
13 : resource_(path),
14 buffer_(NULL),
15 length_(0) {
16 }
17
18 ~Sample() {
19 Unload();
20 }
21
22 const char* path() {
23 return resource_.path();
24 }
25
26 uint8_t* buffer() {
27 return buffer_;
28 }
29
30 off_t length() {
31 return length_;
32 }
33
34 int32_t Load() {
35 int32_t rtn = -1;
36 if (resource_.Open() == 0) {
37 buffer_ = new uint8_t[length_ = resource_.length()];
38 rtn = resource_.Read(buffer_, length_);
39 resource_.Close();
40 }
41 return rtn;
42 }
43
44 void Unload() {
45 if (buffer_ != NULL) {
46 delete[] buffer_;
47 buffer_ = NULL;
48 }
49 length_ = 0;
50 }
51
52 private:
53 friend class SoundService;
54 Resource resource_;
55 uint8_t* buffer_;
56 off_t length_;
57 };
58
59 #endif // EMBEDDERS_OPENGLUI_COMMON_SAMPLE_H_
60
OLDNEW
« no previous file with comments | « runtime/embedders/openglui/common/resource.h ('k') | runtime/embedders/openglui/common/sound_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698