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

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

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code reviews, fix unittests, add a flag to disable the feature Created 7 years, 3 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
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 "third_party/khronos/GLES2/gl2.h" 14 #include "cc/resources/resource_provider.h"
15 15
16 namespace WebKit { class WebGraphicsContext3D; } 16 namespace WebKit { class WebGraphicsContext3D; }
17 17
18 namespace gfx { 18 namespace gfx {
19 class Rect; 19 class Rect;
20 class Size; 20 class Size;
21 class Vector2d; 21 class Vector2d;
22 } 22 }
23 23
24 namespace cc { 24 namespace cc {
25 25
26 class CC_EXPORT TextureUploader { 26 class CC_EXPORT TextureUploader {
27 public: 27 public:
28 static scoped_ptr<TextureUploader> Create( 28 static scoped_ptr<TextureUploader> Create(
29 WebKit::WebGraphicsContext3D* context, 29 WebKit::WebGraphicsContext3D* context,
30 bool use_map_tex_sub_image, 30 bool use_map_tex_sub_image,
31 bool use_shallow_flush) { 31 bool use_shallow_flush) {
32 return make_scoped_ptr( 32 return make_scoped_ptr(
33 new TextureUploader(context, use_map_tex_sub_image, use_shallow_flush)); 33 new TextureUploader(context,
34 use_map_tex_sub_image,
35 use_shallow_flush));
34 } 36 }
35 ~TextureUploader(); 37 ~TextureUploader();
36 38
37 size_t NumBlockingUploads(); 39 size_t NumBlockingUploads();
38 void MarkPendingUploadsAsNonBlocking(); 40 void MarkPendingUploadsAsNonBlocking();
39 double EstimatedTexturesPerSecond(); 41 double EstimatedTexturesPerSecond();
40 42
41 // Let content_rect be a rectangle, and let content_rect be a sub-rectangle of 43 // Let content_rect be a rectangle, and let content_rect be a sub-rectangle of
42 // content_rect, expressed in the same coordinate system as content_rect. Let 44 // content_rect, expressed in the same coordinate system as content_rect. Let
43 // image be a buffer for content_rect. This function will copy the region 45 // image be a buffer for content_rect. This function will copy the region
44 // corresponding to source_rect to dest_offset in this sub-image. 46 // corresponding to source_rect to dest_offset in this sub-image.
45 void Upload(const uint8* image, 47 void Upload(const uint8* image,
46 gfx::Rect content_rect, 48 gfx::Rect content_rect,
47 gfx::Rect source_rect, 49 gfx::Rect source_rect,
48 gfx::Vector2d dest_offset, 50 gfx::Vector2d dest_offset,
49 GLenum format, 51 ResourceProvider::Format format,
50 gfx::Size size); 52 gfx::Size size);
51 53
52 void Flush(); 54 void Flush();
53 void ReleaseCachedQueries(); 55 void ReleaseCachedQueries();
54 56
55 private: 57 private:
56 class Query { 58 class Query {
57 public: 59 public:
58 static scoped_ptr<Query> Create(WebKit::WebGraphicsContext3D* context) { 60 static scoped_ptr<Query> Create(WebKit::WebGraphicsContext3D* context) {
59 return make_scoped_ptr(new Query(context)); 61 return make_scoped_ptr(new Query(context));
(...skipping 30 matching lines...) Expand all
90 bool use_shallow_flush); 92 bool use_shallow_flush);
91 93
92 void BeginQuery(); 94 void BeginQuery();
93 void EndQuery(); 95 void EndQuery();
94 void ProcessQueries(); 96 void ProcessQueries();
95 97
96 void UploadWithTexSubImage(const uint8* image, 98 void UploadWithTexSubImage(const uint8* image,
97 gfx::Rect image_rect, 99 gfx::Rect image_rect,
98 gfx::Rect source_rect, 100 gfx::Rect source_rect,
99 gfx::Vector2d dest_offset, 101 gfx::Vector2d dest_offset,
100 GLenum format); 102 ResourceProvider::Format format);
101 void UploadWithMapTexSubImage(const uint8* image, 103 void UploadWithMapTexSubImage(const uint8* image,
102 gfx::Rect image_rect, 104 gfx::Rect image_rect,
103 gfx::Rect source_rect, 105 gfx::Rect source_rect,
104 gfx::Vector2d dest_offset, 106 gfx::Vector2d dest_offset,
105 GLenum format); 107 ResourceProvider::Format format);
106 108
107 WebKit::WebGraphicsContext3D* context_; 109 WebKit::WebGraphicsContext3D* context_;
108 ScopedPtrDeque<Query> pending_queries_; 110 ScopedPtrDeque<Query> pending_queries_;
109 ScopedPtrDeque<Query> available_queries_; 111 ScopedPtrDeque<Query> available_queries_;
110 std::multiset<double> textures_per_second_history_; 112 std::multiset<double> textures_per_second_history_;
111 size_t num_blocking_texture_uploads_; 113 size_t num_blocking_texture_uploads_;
112 114
113 bool use_map_tex_sub_image_; 115 bool use_map_tex_sub_image_;
114 size_t sub_image_size_; 116 size_t sub_image_size_;
115 scoped_ptr<uint8[]> sub_image_; 117 scoped_ptr<uint8[]> sub_image_;
116 118
117 bool use_shallow_flush_; 119 bool use_shallow_flush_;
118 size_t num_texture_uploads_since_last_flush_; 120 size_t num_texture_uploads_since_last_flush_;
119 121
120 DISALLOW_COPY_AND_ASSIGN(TextureUploader); 122 DISALLOW_COPY_AND_ASSIGN(TextureUploader);
121 }; 123 };
122 124
123 } // namespace cc 125 } // namespace cc
124 126
125 #endif // CC_SCHEDULER_TEXTURE_UPLOADER_H_ 127 #endif // CC_SCHEDULER_TEXTURE_UPLOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698