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

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

Issue 1154053002: gpu: Use a rectangle to keep track of the cleared area of each texture level. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: v2 Created 5 years, 7 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 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 <list> 7 #include <list>
8 8
9 #include "base/memory/linked_ptr.h" 9 #include "base/memory/linked_ptr.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 277 }
278 278
279 TextureDefinition::LevelInfo::LevelInfo() 279 TextureDefinition::LevelInfo::LevelInfo()
280 : target(0), 280 : target(0),
281 internal_format(0), 281 internal_format(0),
282 width(0), 282 width(0),
283 height(0), 283 height(0),
284 depth(0), 284 depth(0),
285 border(0), 285 border(0),
286 format(0), 286 format(0),
287 type(0), 287 type(0) {
288 cleared(false) {
289 } 288 }
290 289
291 TextureDefinition::LevelInfo::LevelInfo(GLenum target, 290 TextureDefinition::LevelInfo::LevelInfo(GLenum target,
292 GLenum internal_format, 291 GLenum internal_format,
293 GLsizei width, 292 GLsizei width,
294 GLsizei height, 293 GLsizei height,
295 GLsizei depth, 294 GLsizei depth,
296 GLint border, 295 GLint border,
297 GLenum format, 296 GLenum format,
298 GLenum type, 297 GLenum type,
299 bool cleared) 298 const gfx::Rect& cleared_rect)
300 : target(target), 299 : target(target),
301 internal_format(internal_format), 300 internal_format(internal_format),
302 width(width), 301 width(width),
303 height(height), 302 height(height),
304 depth(depth), 303 depth(depth),
305 border(border), 304 border(border),
306 format(format), 305 format(format),
307 type(type), 306 type(type),
308 cleared(cleared) {} 307 cleared_rect(cleared_rect) {
308 }
309 309
310 TextureDefinition::LevelInfo::~LevelInfo() {} 310 TextureDefinition::LevelInfo::~LevelInfo() {}
311 311
312 TextureDefinition::TextureDefinition() 312 TextureDefinition::TextureDefinition()
313 : version_(0), 313 : version_(0),
314 target_(0), 314 target_(0),
315 min_filter_(0), 315 min_filter_(0),
316 mag_filter_(0), 316 mag_filter_(0),
317 wrap_s_(0), 317 wrap_s_(0),
318 wrap_t_(0), 318 wrap_t_(0),
(...skipping 26 matching lines...) Expand all
345 scoped_refptr<gfx::GLImage> gl_image( 345 scoped_refptr<gfx::GLImage> gl_image(
346 new GLImageSync(image_buffer_, 346 new GLImageSync(image_buffer_,
347 gfx::Size(first_face.level_infos[0].width, 347 gfx::Size(first_face.level_infos[0].width,
348 first_face.level_infos[0].height))); 348 first_face.level_infos[0].height)));
349 texture->SetLevelImage(NULL, target_, 0, gl_image.get()); 349 texture->SetLevelImage(NULL, target_, 0, gl_image.get());
350 } 350 }
351 351
352 const Texture::LevelInfo& level = first_face.level_infos[0]; 352 const Texture::LevelInfo& level = first_face.level_infos[0];
353 level_info_ = LevelInfo(level.target, level.internal_format, level.width, 353 level_info_ = LevelInfo(level.target, level.internal_format, level.width,
354 level.height, level.depth, level.border, level.format, 354 level.height, level.depth, level.border, level.format,
355 level.type, level.cleared); 355 level.type, level.cleared_rect);
356 } 356 }
357 357
358 TextureDefinition::~TextureDefinition() { 358 TextureDefinition::~TextureDefinition() {
359 } 359 }
360 360
361 Texture* TextureDefinition::CreateTexture() const { 361 Texture* TextureDefinition::CreateTexture() const {
362 GLuint texture_id; 362 GLuint texture_id;
363 glGenTextures(1, &texture_id); 363 glGenTextures(1, &texture_id);
364 364
365 Texture* texture(new Texture(texture_id)); 365 Texture* texture(new Texture(texture_id));
(...skipping 18 matching lines...) Expand all
384 // though. 384 // though.
385 glFlush(); 385 glFlush();
386 386
387 if (defined_) { 387 if (defined_) {
388 texture->face_infos_.resize(1); 388 texture->face_infos_.resize(1);
389 texture->face_infos_[0].level_infos.resize(1); 389 texture->face_infos_[0].level_infos.resize(1);
390 texture->SetLevelInfo(NULL, level_info_.target, 0, 390 texture->SetLevelInfo(NULL, level_info_.target, 0,
391 level_info_.internal_format, level_info_.width, 391 level_info_.internal_format, level_info_.width,
392 level_info_.height, level_info_.depth, 392 level_info_.height, level_info_.depth,
393 level_info_.border, level_info_.format, 393 level_info_.border, level_info_.format,
394 level_info_.type, level_info_.cleared); 394 level_info_.type, level_info_.cleared_rect);
395 } 395 }
396 396
397 if (image_buffer_.get()) { 397 if (image_buffer_.get()) {
398 texture->SetLevelImage( 398 texture->SetLevelImage(
399 NULL, 399 NULL,
400 target_, 400 target_,
401 0, 401 0,
402 new GLImageSync( 402 new GLImageSync(
403 image_buffer_, 403 image_buffer_,
404 gfx::Size(level_info_.width, level_info_.height))); 404 gfx::Size(level_info_.width, level_info_.height)));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 return false; 451 return false;
452 452
453 // All structural changes should have orphaned the texture. 453 // All structural changes should have orphaned the texture.
454 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0)) 454 if (image_buffer_.get() && !texture->GetLevelImage(texture->target(), 0))
455 return false; 455 return false;
456 456
457 return true; 457 return true;
458 } 458 }
459 459
460 bool TextureDefinition::SafeToRenderFrom() const { 460 bool TextureDefinition::SafeToRenderFrom() const {
461 return level_info_.cleared; 461 return level_info_.cleared_rect.Contains(
462 gfx::Rect(level_info_.width, level_info_.height));
462 } 463 }
463 464
464 } // namespace gles2 465 } // namespace gles2
465 } // namespace gpu 466 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698