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

Side by Side Diff: gpu/command_buffer/service/texture_manager.h

Issue 11428140: gpu: Add async pixel transfer interface, stub and tests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address Feedback. Created 8 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
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 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
7 7
8 #include <list>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "gpu/command_buffer/service/feature_info.h" 15 #include "gpu/command_buffer/service/feature_info.h"
15 #include "gpu/command_buffer/service/gl_utils.h" 16 #include "gpu/command_buffer/service/gl_utils.h"
16 #include "gpu/command_buffer/service/memory_tracking.h" 17 #include "gpu/command_buffer/service/memory_tracking.h"
17 #include "gpu/gpu_export.h" 18 #include "gpu/gpu_export.h"
19 #include "ui/gl/async_pixel_transfer_delegate.h"
18 #include "ui/gl/gl_image.h" 20 #include "ui/gl/gl_image.h"
19 21
20 namespace gpu { 22 namespace gpu {
21 namespace gles2 { 23 namespace gles2 {
22 24
23 class GLES2Decoder; 25 class GLES2Decoder;
24 class Display; 26 class Display;
25 class TextureDefinition; 27 class TextureDefinition;
26 28
27 // This class keeps track of the textures and their sizes so we can do NPOT and 29 // This class keeps track of the textures and their sizes so we can do NPOT and
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 173 }
172 174
173 void SetStreamTexture(bool stream_texture) { 175 void SetStreamTexture(bool stream_texture) {
174 stream_texture_ = stream_texture; 176 stream_texture_ = stream_texture;
175 } 177 }
176 178
177 int IsStreamTexture() { 179 int IsStreamTexture() {
178 return stream_texture_; 180 return stream_texture_;
179 } 181 }
180 182
183 gfx::AsyncPixelTransferState* GetAsyncTransferState() const {
184 return async_transfer_state_.get();
185 }
186 void SetAsyncTransferState(scoped_ptr<gfx::AsyncPixelTransferState> state) {
187 async_transfer_state_ = state.Pass();
188 }
189 bool AsyncTransferIsInProgress() {
190 return async_transfer_state_ &&
191 async_transfer_state_->TransferIsInProgress();
192 }
193
181 void SetImmutable(bool immutable) { 194 void SetImmutable(bool immutable) {
182 immutable_ = immutable; 195 immutable_ = immutable;
183 } 196 }
184 197
185 bool IsImmutable() { 198 bool IsImmutable() {
186 return immutable_; 199 return immutable_;
187 } 200 }
188 201
189 // Whether a particular level/face is cleared. 202 // Whether a particular level/face is cleared.
190 bool IsLevelCleared(GLenum target, GLint level); 203 bool IsLevelCleared(GLenum target, GLint level);
191 204
205 // Whether the texture has been defined
206 bool IsDefined() {
207 return estimated_size() > 0;
208 }
209
192 private: 210 private:
193 friend class TextureManager; 211 friend class TextureManager;
194 friend class base::RefCounted<TextureInfo>; 212 friend class base::RefCounted<TextureInfo>;
195 213
196 ~TextureInfo(); 214 ~TextureInfo();
197 215
198 struct LevelInfo { 216 struct LevelInfo {
199 LevelInfo(); 217 LevelInfo();
200 LevelInfo(const LevelInfo& rhs); 218 LevelInfo(const LevelInfo& rhs);
201 ~LevelInfo(); 219 ~LevelInfo();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // The number of framebuffers this texture is attached to. 352 // The number of framebuffers this texture is attached to.
335 int framebuffer_attachment_count_; 353 int framebuffer_attachment_count_;
336 354
337 // Whether the associated context group owns this texture and should delete 355 // Whether the associated context group owns this texture and should delete
338 // it. 356 // it.
339 bool owned_; 357 bool owned_;
340 358
341 // Whether this is a special streaming texture. 359 // Whether this is a special streaming texture.
342 bool stream_texture_; 360 bool stream_texture_;
343 361
362 // State to facilitate async transfers on this texture.
363 scoped_ptr<gfx::AsyncPixelTransferState> async_transfer_state_;
364
344 // Whether the texture is immutable and no further changes to the format 365 // Whether the texture is immutable and no further changes to the format
345 // or dimensions of the texture object can be made. 366 // or dimensions of the texture object can be made.
346 bool immutable_; 367 bool immutable_;
347 368
348 // Size in bytes this texture is assumed to take in memory. 369 // Size in bytes this texture is assumed to take in memory.
349 uint32 estimated_size_; 370 uint32 estimated_size_;
350 371
351 DISALLOW_COPY_AND_ASSIGN(TextureInfo); 372 DISALLOW_COPY_AND_ASSIGN(TextureInfo);
352 }; 373 };
353 374
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 GLenum target, 544 GLenum target,
524 GLint level, 545 GLint level,
525 gfx::GLImage* image); 546 gfx::GLImage* image);
526 547
527 void AddToSignature( 548 void AddToSignature(
528 TextureInfo* info, 549 TextureInfo* info,
529 GLenum target, 550 GLenum target,
530 GLint level, 551 GLint level,
531 std::string* signature) const; 552 std::string* signature) const;
532 553
554 // Transfers added will get their TextureInfo updated at the same time
555 // the async transfer is bound to the real texture.
556 void AddPendingAsyncPixelTransfer(
557 base::WeakPtr<gfx::AsyncPixelTransferState> state, TextureInfo* info);
558 void BindFinishedAsyncPixelTransfers(bool* texture_dirty,
559 bool* framebuffer_dirty);
560
533 private: 561 private:
534 // Helper for Initialize(). 562 // Helper for Initialize().
535 TextureInfo::Ref CreateDefaultAndBlackTextures( 563 TextureInfo::Ref CreateDefaultAndBlackTextures(
536 GLenum target, 564 GLenum target,
537 GLuint* black_texture); 565 GLuint* black_texture);
538 566
539 void StartTracking(TextureInfo* info); 567 void StartTracking(TextureInfo* info);
540 void StopTracking(TextureInfo* info); 568 void StopTracking(TextureInfo* info);
541 569
542 MemoryTypeTracker* GetMemTracker(GLenum texture_pool); 570 MemoryTypeTracker* GetMemTracker(GLenum texture_pool);
(...skipping 22 matching lines...) Expand all
565 bool have_context_; 593 bool have_context_;
566 594
567 // Black (0,0,0,1) textures for when non-renderable textures are used. 595 // Black (0,0,0,1) textures for when non-renderable textures are used.
568 // NOTE: There is no corresponding TextureInfo for these textures. 596 // NOTE: There is no corresponding TextureInfo for these textures.
569 // TextureInfos are only for textures the client side can access. 597 // TextureInfos are only for textures the client side can access.
570 GLuint black_texture_ids_[kNumDefaultTextures]; 598 GLuint black_texture_ids_[kNumDefaultTextures];
571 599
572 // The default textures for each target (texture name = 0) 600 // The default textures for each target (texture name = 0)
573 TextureInfo::Ref default_textures_[kNumDefaultTextures]; 601 TextureInfo::Ref default_textures_[kNumDefaultTextures];
574 602
603 // Async texture allocations which haven't been bound to their textures
604 // yet. This facilitates updating the TextureInfo at the same time the
605 // real texture data is bound.
606 typedef std::pair<base::WeakPtr<gfx::AsyncPixelTransferState>,
607 TextureInfo*> PendingAsyncTransfer;
608 typedef std::list<PendingAsyncTransfer> PendingAsyncTransferList;
609 PendingAsyncTransferList pending_async_transfers_;
610
575 DISALLOW_COPY_AND_ASSIGN(TextureManager); 611 DISALLOW_COPY_AND_ASSIGN(TextureManager);
576 }; 612 };
577 613
578 } // namespace gles2 614 } // namespace gles2
579 } // namespace gpu 615 } // namespace gpu
580 616
581 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 617 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/query_manager.cc ('k') | gpu/command_buffer/service/texture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698