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

Side by Side Diff: runtime/embedders/openglui/emulator/emulator_resource.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_EMULATOR_EMULATOR_RESOURCE_H_
6 #define EMBEDDERS_OPENGLUI_EMULATOR_EMULATOR_RESOURCE_H_
7
8 #include <fcntl.h>
9 #include <sys/stat.h>
10 #include <sys/types.h>
11
12 #include "embedders/openglui/common/log.h"
13 #include "embedders/openglui/common/resource.h"
14
15 class EmulatorResource : public Resource {
16 public:
17 explicit EmulatorResource(const char* path)
18 : base(path),
19 fd_(-1) {
20 }
21
22 int32_t descriptor() {
23 if (fd_ < 0) {
24 Open();
25 }
26 return fd_;
27 }
28
29 off_t length() {
30 if (length_ < 0) {
31 length_ = lseek(fd), 0, SEEK_END);
32 lseek(fd), 0, SEEK_START);
33 }
34 return length_;
35 }
36
37 int32_t Open() {
38 fd_ = open(path_, 0);
39 if (fd_ >= 0) {
40 return 0;
41 }
42 LOGE("Could not open asset %s", path_);
43 return -1;
44 }
45
46 void Close() {
47 if (fd_ >= 0) {
48 close(fd_);
49 fd_ = -1;
50 }
51 }
52
53 int32_t Read(void* buffer, size_t count) {
54 size_t actual = read(asset_, buffer, count);
55 return (actual == count) ? 0 : -1;
56 }
57
58 private:
59 int fd_;
60 };
61
62 #endif // EMBEDDERS_OPENGLUI_EMULATOR_EMULATOR_RESOURCE_H_
63
OLDNEW
« no previous file with comments | « runtime/embedders/openglui/emulator/emulator_graphics_handler.cc ('k') | runtime/embedders/openglui/openglui_embedder.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698