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

Side by Side Diff: components/bitmap_uploader/bitmap_uploader.cc

Issue 2113533002: Makes BitmapUploader handle null GLES2Context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « components/bitmap_uploader/bitmap_uploader.h ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/bitmap_uploader/bitmap_uploader.h" 5 #include "components/bitmap_uploader/bitmap_uploader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 28 matching lines...) Expand all
39 BitmapUploader::~BitmapUploader() { 39 BitmapUploader::~BitmapUploader() {
40 } 40 }
41 41
42 void BitmapUploader::Init(shell::Connector* connector) { 42 void BitmapUploader::Init(shell::Connector* connector) {
43 surface_ = window_->RequestSurface(mus::mojom::SurfaceType::DEFAULT); 43 surface_ = window_->RequestSurface(mus::mojom::SurfaceType::DEFAULT);
44 surface_->BindToThread(); 44 surface_->BindToThread();
45 surface_->set_client(this); 45 surface_->set_client(this);
46 46
47 gles2_context_ = mus::GLES2Context::CreateOffscreenContext( 47 gles2_context_ = mus::GLES2Context::CreateOffscreenContext(
48 std::vector<int32_t>(), connector); 48 std::vector<int32_t>(), connector);
49 DCHECK(gles2_context_); 49 // CreateOffscreenContext() may return null.
50 } 50 }
51 51
52 // Sets the color which is RGBA. 52 // Sets the color which is RGBA.
53 void BitmapUploader::SetColor(uint32_t color) { 53 void BitmapUploader::SetColor(uint32_t color) {
54 if (color_ == color) 54 if (color_ == color)
55 return; 55 return;
56 color_ = color; 56 color_ = color;
57 if (surface_) 57 if (surface_)
58 Upload(); 58 Upload();
59 } 59 }
60 60
61 // Sets a bitmap. 61 // Sets a bitmap.
62 void BitmapUploader::SetBitmap(int width, 62 void BitmapUploader::SetBitmap(int width,
63 int height, 63 int height,
64 std::unique_ptr<std::vector<unsigned char>> data, 64 std::unique_ptr<std::vector<unsigned char>> data,
65 Format format) { 65 Format format) {
66 width_ = width; 66 width_ = width;
67 height_ = height; 67 height_ = height;
68 bitmap_ = std::move(data); 68 bitmap_ = std::move(data);
69 format_ = format; 69 format_ = format;
70 if (surface_) 70 if (surface_)
71 Upload(); 71 Upload();
72 } 72 }
73 73
74 void BitmapUploader::Upload() { 74 void BitmapUploader::Upload() {
75 if (!gles2_context_)
76 return;
77
75 const gfx::Rect bounds(window_->bounds().size()); 78 const gfx::Rect bounds(window_->bounds().size());
76 79
77 cc::CompositorFrame frame; 80 cc::CompositorFrame frame;
78 // TODO(rjkroege): Support device scale factors other than 1. 81 // TODO(rjkroege): Support device scale factors other than 1.
79 frame.metadata.device_scale_factor = 1.0f; 82 frame.metadata.device_scale_factor = 1.0f;
80 frame.delegated_frame_data.reset(new cc::DelegatedFrameData()); 83 frame.delegated_frame_data.reset(new cc::DelegatedFrameData());
81 frame.delegated_frame_data->resource_list.resize(0u); 84 frame.delegated_frame_data->resource_list.resize(0u);
82 85
83 const cc::RenderPassId render_pass_id(1, 1); 86 const cc::RenderPassId render_pass_id(1, 1);
84 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); 87 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 DCHECK_EQ(1, resource.count); 201 DCHECK_EQ(1, resource.count);
199 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData()); 202 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData());
200 uint32_t texture_id = resource_to_texture_id_map_[resource.id]; 203 uint32_t texture_id = resource_to_texture_id_map_[resource.id];
201 DCHECK_NE(0u, texture_id); 204 DCHECK_NE(0u, texture_id);
202 resource_to_texture_id_map_.erase(resource.id); 205 resource_to_texture_id_map_.erase(resource.id);
203 gl->DeleteTextures(1, &texture_id); 206 gl->DeleteTextures(1, &texture_id);
204 } 207 }
205 } 208 }
206 209
207 } // namespace bitmap_uploader 210 } // namespace bitmap_uploader
OLDNEW
« no previous file with comments | « components/bitmap_uploader/bitmap_uploader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698