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

Side by Side Diff: cc/resource_provider.cc

Issue 11428127: cc: Avoid unnecessary flush when releasing a pixel buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | 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 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 #include "cc/resource_provider.h" 5 #include "cc/resource_provider.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 void ResourceProvider::acquirePixelBuffer(ResourceId id) 679 void ResourceProvider::acquirePixelBuffer(ResourceId id)
680 { 680 {
681 DCHECK(m_threadChecker.CalledOnValidThread()); 681 DCHECK(m_threadChecker.CalledOnValidThread());
682 ResourceMap::iterator it = m_resources.find(id); 682 ResourceMap::iterator it = m_resources.find(id);
683 CHECK(it != m_resources.end()); 683 CHECK(it != m_resources.end());
684 Resource* resource = &it->second; 684 Resource* resource = &it->second;
685 DCHECK(!resource->external); 685 DCHECK(!resource->external);
686 DCHECK(!resource->exported); 686 DCHECK(!resource->exported);
687 687
688 if (resource->glId) { 688 if (resource->glId) {
689 if (resource->glPixelBufferId)
690 return;
691 WebGraphicsContext3D* context3d = m_context->context3D(); 689 WebGraphicsContext3D* context3d = m_context->context3D();
692 DCHECK(context3d); 690 DCHECK(context3d);
693 resource->glPixelBufferId = context3d->createBuffer(); 691 if (!resource->glPixelBufferId)
692 resource->glPixelBufferId = context3d->createBuffer();
694 context3d->bindBuffer( 693 context3d->bindBuffer(
695 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 694 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
696 resource->glPixelBufferId); 695 resource->glPixelBufferId);
697 context3d->bufferData( 696 context3d->bufferData(
698 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 697 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
699 resource->size.width() * resource->size.height() * 4, 698 resource->size.width() * resource->size.height() * 4,
700 NULL, 699 NULL,
701 GL_DYNAMIC_DRAW); 700 GL_DYNAMIC_DRAW);
702 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0); 701 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
703 } 702 }
(...skipping 10 matching lines...) Expand all
714 void ResourceProvider::releasePixelBuffer(ResourceId id) 713 void ResourceProvider::releasePixelBuffer(ResourceId id)
715 { 714 {
716 DCHECK(m_threadChecker.CalledOnValidThread()); 715 DCHECK(m_threadChecker.CalledOnValidThread());
717 ResourceMap::iterator it = m_resources.find(id); 716 ResourceMap::iterator it = m_resources.find(id);
718 CHECK(it != m_resources.end()); 717 CHECK(it != m_resources.end());
719 Resource* resource = &it->second; 718 Resource* resource = &it->second;
720 DCHECK(!resource->external); 719 DCHECK(!resource->external);
721 DCHECK(!resource->exported); 720 DCHECK(!resource->exported);
722 721
723 if (resource->glId) { 722 if (resource->glId) {
724 if (!resource->glPixelBufferId) 723 DCHECK(resource->glPixelBufferId);
725 return;
726 WebGraphicsContext3D* context3d = m_context->context3D(); 724 WebGraphicsContext3D* context3d = m_context->context3D();
727 DCHECK(context3d); 725 DCHECK(context3d);
728 context3d->deleteBuffer(resource->glPixelBufferId); 726 context3d->bindBuffer(
729 resource->glPixelBufferId = 0; 727 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
728 resource->glPixelBufferId);
729 context3d->bufferData(
730 GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM,
731 0,
732 NULL,
733 GL_DYNAMIC_DRAW);
734 context3d->bindBuffer(GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM, 0);
730 } 735 }
731 736
732 if (resource->pixels) { 737 if (resource->pixels) {
733 if (!resource->pixelBuffer) 738 if (!resource->pixelBuffer)
734 return; 739 return;
735 delete[] resource->pixelBuffer; 740 delete[] resource->pixelBuffer;
736 resource->pixelBuffer = 0; 741 resource->pixelBuffer = 0;
737 } 742 }
738 } 743 }
739 744
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 resource->size.height()); 834 resource->size.height());
830 src.setPixels(resource->pixelBuffer); 835 src.setPixels(resource->pixelBuffer);
831 836
832 ScopedWriteLockSoftware lock(this, id); 837 ScopedWriteLockSoftware lock(this, id);
833 SkCanvas* dest = lock.skCanvas(); 838 SkCanvas* dest = lock.skCanvas();
834 dest->writePixels(src, 0, 0); 839 dest->writePixels(src, 0, 0);
835 } 840 }
836 } 841 }
837 842
838 } // namespace cc 843 } // namespace cc
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