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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell_renderer.cc

Issue 2837973002: VRShell: Composing Daydream controller textures from patches (Closed)
Patch Set: Separate patches and doing patching in CPU Created 3 years, 8 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/android/vr_shell/vr_shell_renderer.h" 5 #include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 10
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 glBufferData(GL_ELEMENT_ARRAY_BUFFER, model->IndicesBufferSize(), 601 glBufferData(GL_ELEMENT_ARRAY_BUFFER, model->IndicesBufferSize(),
602 model->IndicesBuffer(), GL_STATIC_DRAW); 602 model->IndicesBuffer(), GL_STATIC_DRAW);
603 603
604 glGenBuffersARB(1, &vertex_buffer_); 604 glGenBuffersARB(1, &vertex_buffer_);
605 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_); 605 glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
606 glBufferData(GL_ARRAY_BUFFER, model->ElementsBufferSize(), 606 glBufferData(GL_ARRAY_BUFFER, model->ElementsBufferSize(),
607 model->ElementsBuffer(), GL_STATIC_DRAW); 607 model->ElementsBuffer(), GL_STATIC_DRAW);
608 608
609 glGenTextures(VrControllerModel::STATE_COUNT, texture_handles_.data()); 609 glGenTextures(VrControllerModel::STATE_COUNT, texture_handles_.data());
610 for (int i = 0; i < VrControllerModel::STATE_COUNT; i++) { 610 for (int i = 0; i < VrControllerModel::STATE_COUNT; i++) {
611 sk_sp<SkImage> texture = model->GetTexture(i);
612 SkPixmap pixmap;
613 if (!texture->peekPixels(&pixmap)) {
614 LOG(ERROR) << "Failed to read controller texture pixels";
615 continue;
616 }
611 glBindTexture(GL_TEXTURE_2D, texture_handles_[i]); 617 glBindTexture(GL_TEXTURE_2D, texture_handles_[i]);
612 const SkBitmap* bitmap = model->GetTexture(i);
613 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmap->width(), bitmap->height(),
614 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap->getPixels());
615 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 618 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
616 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 619 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
617 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 620 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
618 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 621 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
622 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap.width(), pixmap.height(), 0,
623 GL_RGBA, GL_UNSIGNED_BYTE, pixmap.addr());
619 } 624 }
620 625
621 const gltf::Accessor* accessor = model->PositionAccessor(); 626 const gltf::Accessor* accessor = model->PositionAccessor();
622 position_components_ = gltf::GetTypeComponents(accessor->type); 627 position_components_ = gltf::GetTypeComponents(accessor->type);
623 position_type_ = accessor->component_type; 628 position_type_ = accessor->component_type;
624 position_stride_ = accessor->byte_stride; 629 position_stride_ = accessor->byte_stride;
625 position_offset_ = VOID_OFFSET(accessor->byte_offset); 630 position_offset_ = VOID_OFFSET(accessor->byte_offset);
626 631
627 accessor = model->TextureCoordinateAccessor(); 632 accessor = model->TextureCoordinateAccessor();
628 tex_coord_components_ = gltf::GetTypeComponents(accessor->type); 633 tex_coord_components_ = gltf::GetTypeComponents(accessor->type);
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 GradientGridRenderer* VrShellRenderer::GetGradientGridRenderer() { 850 GradientGridRenderer* VrShellRenderer::GetGradientGridRenderer() {
846 Flush(); 851 Flush();
847 return gradient_grid_renderer_.get(); 852 return gradient_grid_renderer_.get();
848 } 853 }
849 854
850 void VrShellRenderer::Flush() { 855 void VrShellRenderer::Flush() {
851 textured_quad_renderer_->Flush(); 856 textured_quad_renderer_->Flush();
852 } 857 }
853 858
854 } // namespace vr_shell 859 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698