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

Side by Side Diff: cc/scheduler/texture_uploader.h

Issue 105103004: Convert cc resource system over to GLES2Interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « cc/resources/video_resource_updater.cc ('k') | cc/scheduler/texture_uploader.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef CC_SCHEDULER_TEXTURE_UPLOADER_H_ 5 #ifndef CC_SCHEDULER_TEXTURE_UPLOADER_H_
6 #define CC_SCHEDULER_TEXTURE_UPLOADER_H_ 6 #define CC_SCHEDULER_TEXTURE_UPLOADER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
13 #include "cc/base/scoped_ptr_deque.h" 13 #include "cc/base/scoped_ptr_deque.h"
14 #include "cc/resources/resource_provider.h" 14 #include "cc/resources/resource_provider.h"
15 15
16 namespace blink { class WebGraphicsContext3D; }
17
18 namespace gfx { 16 namespace gfx {
19 class Rect; 17 class Rect;
20 class Size; 18 class Size;
21 class Vector2d; 19 class Vector2d;
22 } 20 }
23 21
22 namespace gpu {
23 namespace gles2 {
24 class GLES2Interface;
25 }
26 }
27
24 namespace cc { 28 namespace cc {
25 29
26 class CC_EXPORT TextureUploader { 30 class CC_EXPORT TextureUploader {
27 public: 31 public:
28 static scoped_ptr<TextureUploader> 32 static scoped_ptr<TextureUploader> Create(gpu::gles2::GLES2Interface* gl) {
29 Create(blink::WebGraphicsContext3D* context) { 33 return make_scoped_ptr(new TextureUploader(gl));
30 return make_scoped_ptr(new TextureUploader(context));
31 } 34 }
32 ~TextureUploader(); 35 ~TextureUploader();
33 36
34 size_t NumBlockingUploads(); 37 size_t NumBlockingUploads();
35 void MarkPendingUploadsAsNonBlocking(); 38 void MarkPendingUploadsAsNonBlocking();
36 double EstimatedTexturesPerSecond(); 39 double EstimatedTexturesPerSecond();
37 40
38 // Let content_rect be a rectangle, and let content_rect be a sub-rectangle of 41 // Let content_rect be a rectangle, and let content_rect be a sub-rectangle of
39 // content_rect, expressed in the same coordinate system as content_rect. Let 42 // content_rect, expressed in the same coordinate system as content_rect. Let
40 // image be a buffer for content_rect. This function will copy the region 43 // image be a buffer for content_rect. This function will copy the region
41 // corresponding to source_rect to dest_offset in this sub-image. 44 // corresponding to source_rect to dest_offset in this sub-image.
42 void Upload(const uint8* image, 45 void Upload(const uint8* image,
43 gfx::Rect content_rect, 46 gfx::Rect content_rect,
44 gfx::Rect source_rect, 47 gfx::Rect source_rect,
45 gfx::Vector2d dest_offset, 48 gfx::Vector2d dest_offset,
46 ResourceFormat format, 49 ResourceFormat format,
47 gfx::Size size); 50 gfx::Size size);
48 51
49 void Flush(); 52 void Flush();
50 void ReleaseCachedQueries(); 53 void ReleaseCachedQueries();
51 54
52 private: 55 private:
53 class Query { 56 class Query {
54 public: 57 public:
55 static scoped_ptr<Query> Create(blink::WebGraphicsContext3D* context) { 58 static scoped_ptr<Query> Create(gpu::gles2::GLES2Interface* gl) {
56 return make_scoped_ptr(new Query(context)); 59 return make_scoped_ptr(new Query(gl));
57 } 60 }
58 61
59 virtual ~Query(); 62 virtual ~Query();
60 63
61 void Begin(); 64 void Begin();
62 void End(); 65 void End();
63 bool IsPending(); 66 bool IsPending();
64 unsigned Value(); 67 unsigned Value();
65 size_t TexturesUploaded(); 68 size_t TexturesUploaded();
66 void mark_as_non_blocking() { 69 void mark_as_non_blocking() {
67 is_non_blocking_ = true; 70 is_non_blocking_ = true;
68 } 71 }
69 bool is_non_blocking() const { 72 bool is_non_blocking() const {
70 return is_non_blocking_; 73 return is_non_blocking_;
71 } 74 }
72 75
73 private: 76 private:
74 explicit Query(blink::WebGraphicsContext3D* context); 77 explicit Query(gpu::gles2::GLES2Interface* gl);
75 78
76 blink::WebGraphicsContext3D* context_; 79 gpu::gles2::GLES2Interface* gl_;
77 unsigned query_id_; 80 unsigned query_id_;
78 unsigned value_; 81 unsigned value_;
79 bool has_value_; 82 bool has_value_;
80 bool is_non_blocking_; 83 bool is_non_blocking_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(Query); 85 DISALLOW_COPY_AND_ASSIGN(Query);
83 }; 86 };
84 87
85 explicit TextureUploader(blink::WebGraphicsContext3D* context); 88 explicit TextureUploader(gpu::gles2::GLES2Interface* gl);
86 89
87 void BeginQuery(); 90 void BeginQuery();
88 void EndQuery(); 91 void EndQuery();
89 void ProcessQueries(); 92 void ProcessQueries();
90 93
91 void UploadWithTexSubImage(const uint8* image, 94 void UploadWithTexSubImage(const uint8* image,
92 gfx::Rect image_rect, 95 gfx::Rect image_rect,
93 gfx::Rect source_rect, 96 gfx::Rect source_rect,
94 gfx::Vector2d dest_offset, 97 gfx::Vector2d dest_offset,
95 ResourceFormat format); 98 ResourceFormat format);
96 void UploadWithMapTexSubImage(const uint8* image, 99 void UploadWithMapTexSubImage(const uint8* image,
97 gfx::Rect image_rect, 100 gfx::Rect image_rect,
98 gfx::Rect source_rect, 101 gfx::Rect source_rect,
99 gfx::Vector2d dest_offset, 102 gfx::Vector2d dest_offset,
100 ResourceFormat format); 103 ResourceFormat format);
101 void UploadWithTexImageETC1(const uint8* image, gfx::Size size); 104 void UploadWithTexImageETC1(const uint8* image, gfx::Size size);
102 105
103 blink::WebGraphicsContext3D* context_; 106 gpu::gles2::GLES2Interface* gl_;
104 ScopedPtrDeque<Query> pending_queries_; 107 ScopedPtrDeque<Query> pending_queries_;
105 ScopedPtrDeque<Query> available_queries_; 108 ScopedPtrDeque<Query> available_queries_;
106 std::multiset<double> textures_per_second_history_; 109 std::multiset<double> textures_per_second_history_;
107 size_t num_blocking_texture_uploads_; 110 size_t num_blocking_texture_uploads_;
108 111
109 size_t sub_image_size_; 112 size_t sub_image_size_;
110 scoped_ptr<uint8[]> sub_image_; 113 scoped_ptr<uint8[]> sub_image_;
111 114
112 size_t num_texture_uploads_since_last_flush_; 115 size_t num_texture_uploads_since_last_flush_;
113 116
114 DISALLOW_COPY_AND_ASSIGN(TextureUploader); 117 DISALLOW_COPY_AND_ASSIGN(TextureUploader);
115 }; 118 };
116 119
117 } // namespace cc 120 } // namespace cc
118 121
119 #endif // CC_SCHEDULER_TEXTURE_UPLOADER_H_ 122 #endif // CC_SCHEDULER_TEXTURE_UPLOADER_H_
OLDNEW
« no previous file with comments | « cc/resources/video_resource_updater.cc ('k') | cc/scheduler/texture_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698