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

Side by Side Diff: gpu/command_buffer/client/gpu_memory_buffer_tracker.cc

Issue 14456004: GPU client side changes for GpuMemoryBuffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@glapi
Patch Set: Add missing parameter in GLES2Implementation ctor in GLES2Implementation unittest Created 7 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "../client/gpu_memory_buffer_tracker.h"
6
7 #include "../client/gles2_implementation.h"
8 #include "../client/gpu_memory_buffer.h"
9 #include "../client/image_factory.h"
10 #include "base/memory/scoped_ptr.h"
11
12 namespace gpu {
13 namespace gles2 {
14
15 GpuMemoryBufferTracker::GpuMemoryBufferTracker(ImageFactory* factory)
16 : buffers_(),
17 factory_(factory) {
18 }
19
20 GpuMemoryBufferTracker::~GpuMemoryBufferTracker() {
21 while (!buffers_.empty()) {
22 RemoveBuffer(buffers_.begin()->first);
23 }
24 }
25
26 GLuint GpuMemoryBufferTracker::CreateBuffer(
27 GLsizei width, GLsizei height, GLenum internalformat) {
28 GLuint image_id = 0;
29 DCHECK(factory_);
30 scoped_ptr<GpuMemoryBuffer> buffer =
31 factory_->CreateGpuMemoryBuffer(width, height, internalformat, &image_id);
32
33 std::pair<BufferMap::iterator, bool> result =
34 buffers_.insert(std::make_pair(image_id, buffer.release()));
35 GPU_DCHECK(result.second);
36
37 return image_id;
38 }
39
40 GpuMemoryBuffer* GpuMemoryBufferTracker::GetBuffer(GLuint image_id) {
41 BufferMap::iterator it = buffers_.find(image_id);
42 return (it != buffers_.end()) ? it->second : NULL;
43 }
44
45 void GpuMemoryBufferTracker::RemoveBuffer(GLuint image_id) {
46 BufferMap::iterator buffer_it = buffers_.find(image_id);
47 if (buffer_it != buffers_.end()) {
48 GpuMemoryBuffer* buffer = buffer_it->second;
49 buffers_.erase(buffer_it);
50 delete buffer;
51 }
52 DCHECK(factory_);
53 factory_->DeleteGpuMemoryBuffer(image_id);
54 }
55
56 } // namespace gles2
57 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gpu_memory_buffer_tracker.h ('k') | gpu/command_buffer/client/image_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698