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

Side by Side Diff: cc/blink/web_external_texture_layer_impl.cc

Issue 2212163002: Add some plumbing for the color management of canvases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor corrections Created 4 years, 4 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 | « no previous file | cc/resources/resource_provider.cc » ('j') | cc/resources/resource_provider.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/blink/web_external_texture_layer_impl.h" 5 #include "cc/blink/web_external_texture_layer_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "cc/blink/web_external_bitmap_impl.h" 8 #include "cc/blink/web_external_bitmap_impl.h"
9 #include "cc/blink/web_layer_impl.h" 9 #include "cc/blink/web_layer_impl.h"
10 #include "cc/layers/texture_layer.h" 10 #include "cc/layers/texture_layer.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 void WebExternalTextureLayerImpl::setBlendBackgroundColor(bool blend) { 55 void WebExternalTextureLayerImpl::setBlendBackgroundColor(bool blend) {
56 static_cast<TextureLayer*>(layer_->layer())->SetBlendBackgroundColor(blend); 56 static_cast<TextureLayer*>(layer_->layer())->SetBlendBackgroundColor(blend);
57 } 57 }
58 58
59 void WebExternalTextureLayerImpl::setNearestNeighbor(bool nearest_neighbor) { 59 void WebExternalTextureLayerImpl::setNearestNeighbor(bool nearest_neighbor) {
60 static_cast<TextureLayer*>(layer_->layer()) 60 static_cast<TextureLayer*>(layer_->layer())
61 ->SetNearestNeighbor(nearest_neighbor); 61 ->SetNearestNeighbor(nearest_neighbor);
62 } 62 }
63 63
64 static gfx::ColorSpace toGfxColorSpace(const SkColorSpace* skColorSpace) {
65 // TODO(crbug.com/634102): eliminate this clumsy conversion by unifying
66 // SkColorSpace and gfx::ColorSpace
67 if (!skColorSpace)
68 return gfx::ColorSpace::ColorSpace();
69
70 // assumption: using srgb or linear-rgb
Stephen White 2016/08/11 20:41:27 Assert that assumption?
Justin Novosad 2016/08/12 17:40:18 Done.
71 gfx::ColorSpace::TransferID transfer =
72 skColorSpace->gammaNamed() == SkColorSpace::kSRGB_GammaNamed
73 ? gfx::ColorSpace::TransferID::IEC61966_2_1
74 : gfx::ColorSpace::TransferID::LINEAR;
75 return gfx::ColorSpace::ColorSpace(gfx::ColorSpace::PrimaryID::BT709,
76 transfer, gfx::ColorSpace::MatrixID::RGB,
77 gfx::ColorSpace::RangeID::FULL);
78 }
79
64 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( 80 bool WebExternalTextureLayerImpl::PrepareTextureMailbox(
65 cc::TextureMailbox* mailbox, 81 cc::TextureMailbox* mailbox,
66 std::unique_ptr<cc::SingleReleaseCallback>* release_callback, 82 std::unique_ptr<cc::SingleReleaseCallback>* release_callback,
67 bool use_shared_memory) { 83 bool use_shared_memory) {
68 blink::WebExternalTextureMailbox client_mailbox; 84 blink::WebExternalTextureMailbox client_mailbox;
69 WebExternalBitmapImpl* bitmap = nullptr; 85 WebExternalBitmapImpl* bitmap = nullptr;
70 86
71 if (use_shared_memory) 87 if (use_shared_memory)
72 bitmap = AllocateBitmap(); 88 bitmap = AllocateBitmap();
73 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { 89 if (!client_->prepareMailbox(&client_mailbox, bitmap)) {
(...skipping 16 matching lines...) Expand all
90 if (client_mailbox.allowOverlay) { 106 if (client_mailbox.allowOverlay) {
91 size = gfx::Size(client_mailbox.textureSize.width, 107 size = gfx::Size(client_mailbox.textureSize.width,
92 client_mailbox.textureSize.height); 108 client_mailbox.textureSize.height);
93 } 109 }
94 110
95 *mailbox = cc::TextureMailbox( 111 *mailbox = cc::TextureMailbox(
96 name, sync_token, client_mailbox.textureTarget, size, 112 name, sync_token, client_mailbox.textureTarget, size,
97 client_mailbox.allowOverlay, false); 113 client_mailbox.allowOverlay, false);
98 } 114 }
99 mailbox->set_nearest_neighbor(client_mailbox.nearestNeighbor); 115 mailbox->set_nearest_neighbor(client_mailbox.nearestNeighbor);
116 mailbox->set_color_space(toGfxColorSpace(client_mailbox.colorSpace));
100 117
101 if (mailbox->IsValid()) { 118 if (mailbox->IsValid()) {
102 *release_callback = cc::SingleReleaseCallback::Create( 119 *release_callback = cc::SingleReleaseCallback::Create(
103 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, 120 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox,
104 this->AsWeakPtr(), 121 this->AsWeakPtr(),
105 client_mailbox, 122 client_mailbox,
106 bitmap)); 123 bitmap));
107 } 124 }
108 125
109 return true; 126 return true;
(...skipping 22 matching lines...) Expand all
132 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); 149 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name));
133 memcpy(available_mailbox.syncToken, sync_token.GetConstData(), 150 memcpy(available_mailbox.syncToken, sync_token.GetConstData(),
134 sizeof(sync_token)); 151 sizeof(sync_token));
135 available_mailbox.validSyncToken = sync_token.HasData(); 152 available_mailbox.validSyncToken = sync_token.HasData();
136 if (bitmap) 153 if (bitmap)
137 layer->free_bitmaps_.push_back(base::WrapUnique(bitmap)); 154 layer->free_bitmaps_.push_back(base::WrapUnique(bitmap));
138 layer->client_->mailboxReleased(available_mailbox, lost_resource); 155 layer->client_->mailboxReleased(available_mailbox, lost_resource);
139 } 156 }
140 157
141 } // namespace cc_blink 158 } // namespace cc_blink
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_provider.cc » ('j') | cc/resources/resource_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698