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

Side by Side Diff: core/cross/buffer.cc

Issue 149300: These files were meant to be checked in with ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 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 | « core/cross/buffer.h ('k') | core/cross/object_base_test.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 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 Renderer* renderer = service_locator->GetService<Renderer>(); 484 Renderer* renderer = service_locator->GetService<Renderer>();
485 if (NULL == renderer) { 485 if (NULL == renderer) {
486 O3D_ERROR(service_locator) << "No Render Device Available"; 486 O3D_ERROR(service_locator) << "No Render Device Available";
487 return ObjectBase::Ref(); 487 return ObjectBase::Ref();
488 } 488 }
489 return ObjectBase::Ref(renderer->CreateVertexBuffer()); 489 return ObjectBase::Ref(renderer->CreateVertexBuffer());
490 } 490 }
491 491
492 SourceBuffer::SourceBuffer(ServiceLocator* service_locator) 492 SourceBuffer::SourceBuffer(ServiceLocator* service_locator)
493 : VertexBufferBase(service_locator), 493 : VertexBufferBase(service_locator),
494 buffer_(NULL) { 494 buffer_() {
495 } 495 }
496 496
497 SourceBuffer::~SourceBuffer() { 497 SourceBuffer::~SourceBuffer() {
498 ConcreteFree(); 498 ConcreteFree();
499 } 499 }
500 500
501 void SourceBuffer::ConcreteFree() { 501 void SourceBuffer::ConcreteFree() {
502 if (buffer_) { 502 buffer_.reset();
503 delete [] buffer_;
504 buffer_ = NULL;
505 }
506 } 503 }
507 504
508 bool SourceBuffer::ConcreteAllocate(size_t size_in_bytes) { 505 bool SourceBuffer::ConcreteAllocate(size_t size_in_bytes) {
509 ConcreteFree(); 506 ConcreteFree();
510 507
511 buffer_ = new char[size_in_bytes]; 508 buffer_.reset(new char[size_in_bytes]);
512 509
513 return true; 510 return true;
514 } 511 }
515 512
516 bool SourceBuffer::ConcreteLock(AccessMode access_mode, void **buffer_data) { 513 bool SourceBuffer::ConcreteLock(AccessMode access_mode, void **buffer_data) {
517 if (!buffer_) { 514 if (!buffer_.get()) {
518 return false; 515 return false;
519 } 516 }
520 517
521 *buffer_data = reinterpret_cast<void*>(buffer_); 518 *buffer_data = reinterpret_cast<void*>(buffer_.get());
522 return true; 519 return true;
523 } 520 }
524 521
525 bool SourceBuffer::ConcreteUnlock() { 522 bool SourceBuffer::ConcreteUnlock() {
526 return buffer_ != NULL; 523 return buffer_.get() != NULL;
527 } 524 }
528 525
529 ObjectBase::Ref SourceBuffer::Create(ServiceLocator* service_locator) { 526 ObjectBase::Ref SourceBuffer::Create(ServiceLocator* service_locator) {
530 return ObjectBase::Ref(new SourceBuffer(service_locator)); 527 return ObjectBase::Ref(new SourceBuffer(service_locator));
531 } 528 }
532 529
533 Field* IndexBuffer::index_field() const { 530 Field* IndexBuffer::index_field() const {
534 // TODO: It does not make sense for an IndexBuffer to have more 531 // TODO: It does not make sense for an IndexBuffer to have more
535 // than one field. For example, we do not support any way of rendering a 532 // than one field. For example, we do not support any way of rendering a
536 // primitive using only one of the fields of an IndexBuffer. The API allows 533 // primitive using only one of the fields of an IndexBuffer. The API allows
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 locked_ = buffer_->Lock(access_mode, &data_); 573 locked_ = buffer_->Lock(access_mode, &data_);
577 if (!locked_) { 574 if (!locked_) {
578 O3D_ERROR(buffer_->service_locator()) 575 O3D_ERROR(buffer_->service_locator())
579 << "Unable to lock buffer '" << buffer_->name() << "'"; 576 << "Unable to lock buffer '" << buffer_->name() << "'";
580 } 577 }
581 } 578 }
582 return data_; 579 return data_;
583 } 580 }
584 581
585 } // namespace o3d 582 } // namespace o3d
OLDNEW
« no previous file with comments | « core/cross/buffer.h ('k') | core/cross/object_base_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698