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

Side by Side Diff: gpu/command_buffer/service/texture_definition.cc

Issue 344483006: Fix GLImageSync::GetSize() to return actual texture size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "gpu/command_buffer/service/texture_definition.h" 5 #include "gpu/command_buffer/service/texture_definition.h"
6 6
7 #include "gpu/command_buffer/service/texture_manager.h" 7 #include "gpu/command_buffer/service/texture_manager.h"
8 #include "ui/gl/gl_image.h" 8 #include "ui/gl/gl_image.h"
9 #include "ui/gl/gl_implementation.h" 9 #include "ui/gl/gl_implementation.h"
10 #include "ui/gl/scoped_binders.h" 10 #include "ui/gl/scoped_binders.h"
11 11
12 #if !defined(OS_MACOSX) 12 #if !defined(OS_MACOSX)
13 #include "ui/gl/gl_surface_egl.h" 13 #include "ui/gl/gl_surface_egl.h"
14 #endif 14 #endif
15 15
16 namespace gpu { 16 namespace gpu {
17 namespace gles2 { 17 namespace gles2 {
18 18
19 namespace { 19 namespace {
20 20
21 class GLImageSync : public gfx::GLImage { 21 class GLImageSync : public gfx::GLImage {
22 public: 22 public:
23 explicit GLImageSync( 23 explicit GLImageSync(const scoped_refptr<NativeImageBuffer>& buffer,
24 const scoped_refptr<NativeImageBuffer>& buffer); 24 const gfx::Size& size);
25 25
26 // Implement GLImage. 26 // Implement GLImage.
27 virtual void Destroy() OVERRIDE; 27 virtual void Destroy() OVERRIDE;
28 virtual gfx::Size GetSize() OVERRIDE; 28 virtual gfx::Size GetSize() OVERRIDE;
29 virtual bool BindTexImage(unsigned target) OVERRIDE; 29 virtual bool BindTexImage(unsigned target) OVERRIDE;
30 virtual void ReleaseTexImage(unsigned target) OVERRIDE; 30 virtual void ReleaseTexImage(unsigned target) OVERRIDE;
31 virtual void WillUseTexImage() OVERRIDE; 31 virtual void WillUseTexImage() OVERRIDE;
32 virtual void WillModifyTexImage() OVERRIDE; 32 virtual void WillModifyTexImage() OVERRIDE;
33 virtual void DidModifyTexImage() OVERRIDE; 33 virtual void DidModifyTexImage() OVERRIDE;
34 34
35 virtual void DidUseTexImage() OVERRIDE; 35 virtual void DidUseTexImage() OVERRIDE;
36 virtual void SetReleaseAfterUse() OVERRIDE; 36 virtual void SetReleaseAfterUse() OVERRIDE;
37 37
38 protected: 38 protected:
39 virtual ~GLImageSync(); 39 virtual ~GLImageSync();
40 40
41 private: 41 private:
42 scoped_refptr<NativeImageBuffer> buffer_; 42 scoped_refptr<NativeImageBuffer> buffer_;
43 gfx::Size size_;
43 44
44 DISALLOW_COPY_AND_ASSIGN(GLImageSync); 45 DISALLOW_COPY_AND_ASSIGN(GLImageSync);
45 }; 46 };
46 47
47 GLImageSync::GLImageSync(const scoped_refptr<NativeImageBuffer>& buffer) 48 GLImageSync::GLImageSync(const scoped_refptr<NativeImageBuffer>& buffer,
48 : buffer_(buffer) { 49 const gfx::Size& size)
50 : buffer_(buffer), size_(size) {
49 if (buffer) 51 if (buffer)
50 buffer->AddClient(this); 52 buffer->AddClient(this);
51 } 53 }
52 54
53 GLImageSync::~GLImageSync() { 55 GLImageSync::~GLImageSync() {
54 if (buffer_) 56 if (buffer_)
55 buffer_->RemoveClient(this); 57 buffer_->RemoveClient(this);
56 } 58 }
57 59
58 void GLImageSync::Destroy() {} 60 void GLImageSync::Destroy() {}
59 61
60 gfx::Size GLImageSync::GetSize() { 62 gfx::Size GLImageSync::GetSize() {
61 NOTREACHED(); 63 return size_;
62 return gfx::Size();
63 } 64 }
64 65
65 bool GLImageSync::BindTexImage(unsigned target) { 66 bool GLImageSync::BindTexImage(unsigned target) {
66 NOTREACHED(); 67 NOTREACHED();
67 return false; 68 return false;
68 } 69 }
69 70
70 void GLImageSync::ReleaseTexImage(unsigned target) { 71 void GLImageSync::ReleaseTexImage(unsigned target) {
71 NOTREACHED(); 72 NOTREACHED();
72 } 73 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 usage_(texture->usage()), 333 usage_(texture->usage()),
333 immutable_(texture->IsImmutable()) { 334 immutable_(texture->IsImmutable()) {
334 335
335 // TODO 336 // TODO
336 DCHECK(!texture->level_infos_.empty()); 337 DCHECK(!texture->level_infos_.empty());
337 DCHECK(!texture->level_infos_[0].empty()); 338 DCHECK(!texture->level_infos_[0].empty());
338 DCHECK(!texture->NeedsMips()); 339 DCHECK(!texture->NeedsMips());
339 DCHECK(texture->level_infos_[0][0].width); 340 DCHECK(texture->level_infos_[0][0].width);
340 DCHECK(texture->level_infos_[0][0].height); 341 DCHECK(texture->level_infos_[0][0].height);
341 342
342 scoped_refptr<gfx::GLImage> gl_image(new GLImageSync(image_buffer_)); 343 scoped_refptr<gfx::GLImage> gl_image(
344 new GLImageSync(image_buffer_,
345 gfx::Size(texture->level_infos_[0][0].width,
346 texture->level_infos_[0][0].height)));
343 texture->SetLevelImage(NULL, target, 0, gl_image); 347 texture->SetLevelImage(NULL, target, 0, gl_image);
344 348
345 // TODO: all levels 349 // TODO: all levels
346 level_infos_.clear(); 350 level_infos_.clear();
347 const Texture::LevelInfo& level = texture->level_infos_[0][0]; 351 const Texture::LevelInfo& level = texture->level_infos_[0][0];
348 LevelInfo info(level.target, 352 LevelInfo info(level.target,
349 level.internal_format, 353 level.internal_format,
350 level.width, 354 level.width,
351 level.height, 355 level.height,
352 level.depth, 356 level.depth,
353 level.border, 357 level.border,
354 level.format, 358 level.format,
355 level.type, 359 level.type,
356 level.cleared); 360 level.cleared);
357 std::vector<LevelInfo> infos; 361 std::vector<LevelInfo> infos;
358 infos.push_back(info); 362 infos.push_back(info);
359 level_infos_.push_back(infos); 363 level_infos_.push_back(infos);
360
361 } 364 }
362 365
363 TextureDefinition::~TextureDefinition() { 366 TextureDefinition::~TextureDefinition() {
364 } 367 }
365 368
366 Texture* TextureDefinition::CreateTexture() const { 369 Texture* TextureDefinition::CreateTexture() const {
367 if (!image_buffer_) 370 if (!image_buffer_)
368 return NULL; 371 return NULL;
369 372
370 GLuint texture_id; 373 GLuint texture_id;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 info.internal_format, 410 info.internal_format,
408 info.width, 411 info.width,
409 info.height, 412 info.height,
410 info.depth, 413 info.depth,
411 info.border, 414 info.border,
412 info.format, 415 info.format,
413 info.type, 416 info.type,
414 info.cleared); 417 info.cleared);
415 } 418 }
416 } 419 }
417 if (image_buffer_) 420 if (image_buffer_) {
418 texture->SetLevelImage(NULL, target_, 0, new GLImageSync(image_buffer_)); 421 texture->SetLevelImage(
422 NULL,
423 target_,
424 0,
425 new GLImageSync(
426 image_buffer_,
427 gfx::Size(level_infos_[0][0].width, level_infos_[0][0].height)));
428 }
419 429
420 texture->target_ = target_; 430 texture->target_ = target_;
421 texture->SetImmutable(immutable_); 431 texture->SetImmutable(immutable_);
422 texture->min_filter_ = min_filter_; 432 texture->min_filter_ = min_filter_;
423 texture->mag_filter_ = mag_filter_; 433 texture->mag_filter_ = mag_filter_;
424 texture->wrap_s_ = wrap_s_; 434 texture->wrap_s_ = wrap_s_;
425 texture->wrap_t_ = wrap_t_; 435 texture->wrap_t_ = wrap_t_;
426 texture->usage_ = usage_; 436 texture->usage_ = usage_;
427 } 437 }
428 438
429 bool TextureDefinition::Matches(const Texture* texture) const { 439 bool TextureDefinition::Matches(const Texture* texture) const {
430 DCHECK(target_ == texture->target()); 440 DCHECK(target_ == texture->target());
431 if (texture->min_filter_ != min_filter_ || 441 if (texture->min_filter_ != min_filter_ ||
432 texture->mag_filter_ != mag_filter_ || 442 texture->mag_filter_ != mag_filter_ ||
433 texture->wrap_s_ != wrap_s_ || 443 texture->wrap_s_ != wrap_s_ ||
434 texture->wrap_t_ != wrap_t_) { 444 texture->wrap_t_ != wrap_t_) {
435 return false; 445 return false;
436 } 446 }
437 447
438 // All structural changes should have orphaned the texture. 448 // All structural changes should have orphaned the texture.
439 if (image_buffer_ && !texture->GetLevelImage(texture->target(), 0)) 449 if (image_buffer_ && !texture->GetLevelImage(texture->target(), 0))
440 return false; 450 return false;
441 451
442 return true; 452 return true;
443 } 453 }
444 454
445 } // namespace gles2 455 } // namespace gles2
446 } // namespace gpu 456 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698