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

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

Issue 14456004: GPU client side changes for GpuMemoryBuffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@glapi
Patch Set: Updated the extension documentation 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_in_process.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 GpuMemoryBufferTrackerInProcess::GpuMemoryBufferTrackerInProcess(
reveman 2013/05/10 02:06:16 Why is this in-process specific? You already have
kaanb 2013/05/13 23:00:36 Removed this file.
16 ImageFactory* factory, GLES2Implementation* gl)
17 : buffers_(),
18 factory_(factory),
19 gl_(gl) {
20 }
21
22 GpuMemoryBufferTrackerInProcess::~GpuMemoryBufferTrackerInProcess() {
23 while (!buffers_.empty()) {
24 RemoveBuffer(buffers_.begin()->first);
25 }
26 }
27
28 GLuint GpuMemoryBufferTrackerInProcess::CreateBuffer(GLsizei width,
29 GLsizei height) {
30 // Flush the command stream to make sure all pending commands
31 // that may refer to the image_id are executed on the service side.
32 gl_->Flush();
no sievers 2013/05/10 01:21:51 Hmm I wonder if the flush here and below should be
kaanb 2013/05/13 23:00:36 Done.
33 GLuint image_id = 0;
34 scoped_ptr<GpuMemoryBuffer> buffer =
35 factory_->CreateGpuMemoryBuffer(width, height, &image_id);
36
37 std::pair<BufferMap::iterator, bool> result =
38 buffers_.insert(std::make_pair(image_id, buffer.release()));
39 GPU_DCHECK(result.second);
40
41 return image_id;
42 }
43
44 GpuMemoryBuffer* GpuMemoryBufferTrackerInProcess::GetBuffer(GLuint image_id) {
45 BufferMap::iterator it = buffers_.find(image_id);
46 return (it != buffers_.end()) ? it->second : NULL;
47 }
48
49 void GpuMemoryBufferTrackerInProcess::RemoveBuffer(GLuint image_id) {
50 // Flush the command stream to make sure all pending commands
51 // that may refer to the image_id are executed on the service side.
52 gl_->Flush();
53 BufferMap::iterator buffer_it = buffers_.find(image_id);
54 if (buffer_it != buffers_.end()) {
55 GpuMemoryBuffer* buffer = buffer_it->second;
56 buffers_.erase(buffer_it);
57 delete buffer;
58 }
59 factory_->RemoveFromManager(image_id);
60 }
61
62 } // namespace gles2
63 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698