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

Side by Side Diff: content/common/gpu/stream_texture_manager_android.cc

Issue 10695181: [Android] Upstream all the IPC communications/handlings for stream texture (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove #pragma once Created 8 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 | « content/common/gpu/stream_texture_manager_android.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/common/gpu/stream_texture_manager_android.h" 5 #include "content/common/gpu/stream_texture_manager_android.h"
6 6
7 #include "base/bind.h"
7 #include "content/common/android/surface_texture_bridge.h" 8 #include "content/common/android/surface_texture_bridge.h"
8 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_messages.h"
11 #include "gpu/command_buffer/service/stream_texture.h"
12 #include "ui/gfx/size.h"
9 13
10 namespace content { 14 namespace content {
11 15
12 StreamTextureManagerAndroid::StreamTextureAndroid::StreamTextureAndroid( 16 StreamTextureManagerAndroid::StreamTextureAndroid::StreamTextureAndroid(
13 GpuChannel* channel, int service_id) 17 GpuChannel* channel, int service_id)
14 : surface_texture_(new SurfaceTextureBridge(service_id)), 18 : surface_texture_(new SurfaceTextureBridge(service_id)),
19 has_updated_(false),
15 channel_(channel) { 20 channel_(channel) {
16 NOTIMPLEMENTED(); 21 memset(current_matrix_, 0, sizeof(current_matrix_));
17 } 22 }
18 23
19 StreamTextureManagerAndroid::StreamTextureAndroid::~StreamTextureAndroid() { 24 StreamTextureManagerAndroid::StreamTextureAndroid::~StreamTextureAndroid() {
20 NOTIMPLEMENTED();
21 } 25 }
22 26
23 void StreamTextureManagerAndroid::StreamTextureAndroid::Update() { 27 void StreamTextureManagerAndroid::StreamTextureAndroid::Update() {
24 surface_texture_->UpdateTexImage(); 28 surface_texture_->UpdateTexImage();
29 if (matrix_callback_.is_null())
30 return;
31
32 float mtx[16];
33 surface_texture_->GetTransformMatrix(mtx);
34
35 // Only query the matrix once we have bound a valid frame.
36 if (has_updated_ && memcmp(current_matrix_, mtx, sizeof(mtx)) != 0) {
37 memcpy(current_matrix_, mtx, sizeof(mtx));
38
39 GpuStreamTextureMsg_MatrixChanged_Params params;
40 memcpy(&params.m00, mtx, sizeof(mtx));
41 matrix_callback_.Run(params);
42 }
43 }
44
45 void StreamTextureManagerAndroid::StreamTextureAndroid::OnFrameAvailable(
46 int route_id) {
47 has_updated_ = true;
48 channel_->Send(new GpuStreamTextureMsg_FrameAvailable(route_id));
25 } 49 }
26 50
27 StreamTextureManagerAndroid::StreamTextureManagerAndroid( 51 StreamTextureManagerAndroid::StreamTextureManagerAndroid(
28 GpuChannel* channel) 52 GpuChannel* channel)
29 : channel_(channel) { 53 : channel_(channel) {
30 NOTIMPLEMENTED();
31 } 54 }
32 55
33 StreamTextureManagerAndroid::~StreamTextureManagerAndroid() { 56 StreamTextureManagerAndroid::~StreamTextureManagerAndroid() {
34 NOTIMPLEMENTED(); 57 DCHECK(textures_.size() == textures_from_service_id_.size());
58 if (!textures_.IsEmpty())
59 LOG(WARNING) << "Undestroyed surface textures while closing GPU channel.";
35 } 60 }
36 61
37 GLuint StreamTextureManagerAndroid::CreateStreamTexture(uint32 service_id, 62 GLuint StreamTextureManagerAndroid::CreateStreamTexture(uint32 service_id,
38 uint32 client_id) { 63 uint32 client_id) {
39 // service_id: the actual GL texture name 64 // service_id: the actual GL texture name
40 // client_id: texture name given to the client in the renderer (unused here) 65 // client_id: texture name given to the client in the renderer (unused here)
41 // The return value here is what glCreateStreamTextureCHROMIUM() will return 66 // The return value here is what glCreateStreamTextureCHROMIUM() will return
42 // to identify the stream (i.e. surface texture). 67 // to identify the stream (i.e. surface texture).
43 StreamTextureAndroid* texture = new StreamTextureAndroid( 68 StreamTextureAndroid* texture = new StreamTextureAndroid(
44 channel_, service_id); 69 channel_, service_id);
70 textures_from_service_id_.AddWithID(texture, service_id);
45 return textures_.Add(texture); 71 return textures_.Add(texture);
46 } 72 }
47 73
48 void StreamTextureManagerAndroid::DestroyStreamTexture(uint32 service_id) { 74 void StreamTextureManagerAndroid::DestroyStreamTexture(uint32 service_id) {
49 NOTIMPLEMENTED(); 75 gpu::StreamTexture* texture = textures_from_service_id_.Lookup(service_id);
76 if (texture) {
77 textures_from_service_id_.Remove(service_id);
78
79 for (TextureMap::Iterator<StreamTextureAndroid> it(&textures_);
80 !it.IsAtEnd(); it.Advance()) {
81 if (it.GetCurrentValue() == texture) {
82 textures_.Remove(it.GetCurrentKey());
83 break;
84 }
85 }
86 }
50 } 87 }
51 88
52 gpu::StreamTexture* StreamTextureManagerAndroid::LookupStreamTexture( 89 gpu::StreamTexture* StreamTextureManagerAndroid::LookupStreamTexture(
53 uint32 service_id) { 90 uint32 service_id) {
54 NOTIMPLEMENTED(); 91 return textures_from_service_id_.Lookup(service_id);
55 return NULL; 92 }
93
94 void StreamTextureManagerAndroid::SendMatrixChanged(
95 int route_id,
96 const GpuStreamTextureMsg_MatrixChanged_Params& params) {
97 channel_->Send(new GpuStreamTextureMsg_MatrixChanged(route_id, params));
98 }
99
100 void StreamTextureManagerAndroid::RegisterStreamTextureProxy(
101 int32 stream_id, const gfx::Size& initial_size, int32 route_id) {
102 StreamTextureAndroid* stream_texture = textures_.Lookup(stream_id);
103 if (stream_texture) {
104 // TODO(sievers): Post from binder thread to IO thread directly.
105 base::Closure frame_cb = base::Bind(
106 &StreamTextureAndroid::OnFrameAvailable,
107 stream_texture->AsWeakPtr(),
108 route_id);
109 StreamTextureAndroid::MatrixChangedCB matrix_cb = base::Bind(
110 &StreamTextureManagerAndroid::SendMatrixChanged,
111 base::Unretained(this),
112 route_id);
113 stream_texture->set_matrix_changed_callback(matrix_cb);
114 stream_texture->bridge()->SetFrameAvailableCallback(frame_cb);
115 stream_texture->bridge()->SetDefaultBufferSize(initial_size.width(),
116 initial_size.height());
117 }
118 }
119
120 void StreamTextureManagerAndroid::EstablishStreamTexture(
121 int32 stream_id, SurfaceTexturePeer::SurfaceTextureTarget type,
122 int32 primary_id, int32 secondary_id) {
123 StreamTextureAndroid* stream_texture = textures_.Lookup(stream_id);
124 base::ProcessHandle process = channel_->renderer_pid();
125
126 if (stream_texture) {
127 SurfaceTexturePeer::GetInstance()->EstablishSurfaceTexturePeer(
128 process,
129 type,
130 stream_texture->bridge()->j_surface_texture().obj(),
131 primary_id,
132 secondary_id);
133 }
56 } 134 }
57 135
58 } // namespace content 136 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/stream_texture_manager_android.h ('k') | content/content_renderer.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698