Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { | |
|
danakj
2016/08/12 21:03:48
how about SkColorSpaceToColorSpace (like SkRectToR
Justin Novosad
2016/08/15 18:07:03
Done.
| |
| 65 // TODO(crbug.com/634102): eliminate this clumsy conversion by unifying | |
| 66 // SkColorSpace and gfx::ColorSpace | |
|
danakj
2016/08/12 21:03:48
comments need punctuation and capitalization
Justin Novosad
2016/08/15 18:07:03
Done.
| |
| 67 if (!skColorSpace) | |
| 68 return gfx::ColorSpace(); | |
| 69 | |
| 70 // Assumption: using srgb or linear-rgb | |
|
danakj
2016/08/12 21:03:48
comments need punctuation, should be proper senten
Justin Novosad
2016/08/15 18:07:03
Done.
| |
| 71 DCHECK(skColorSpace->gammaNamed() == SkColorSpace::kSRGB_GammaNamed || | |
| 72 skColorSpace->gammaNamed() == SkColorSpace::kLinear_GammaNamed); | |
| 73 gfx::ColorSpace::TransferID transfer = | |
| 74 skColorSpace->gammaNamed() == SkColorSpace::kSRGB_GammaNamed | |
|
danakj
2016/08/12 21:03:48
can this be a switch instead? so new enum values f
Justin Novosad
2016/08/15 18:07:04
Done.
| |
| 75 ? gfx::ColorSpace::TransferID::IEC61966_2_1 | |
| 76 : gfx::ColorSpace::TransferID::LINEAR; | |
| 77 return gfx::ColorSpace::ColorSpace(gfx::ColorSpace::PrimaryID::BT709, | |
|
danakj
2016/08/12 21:03:48
what is gfx::ColorSpace::ColorSpace()? is that the
Justin Novosad
2016/08/15 18:07:04
This was bad code. somehow the compiler was lettin
| |
| 78 transfer, gfx::ColorSpace::MatrixID::RGB, | |
| 79 gfx::ColorSpace::RangeID::FULL); | |
| 80 } | |
| 81 | |
| 64 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( | 82 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( |
| 65 cc::TextureMailbox* mailbox, | 83 cc::TextureMailbox* mailbox, |
| 66 std::unique_ptr<cc::SingleReleaseCallback>* release_callback, | 84 std::unique_ptr<cc::SingleReleaseCallback>* release_callback, |
| 67 bool use_shared_memory) { | 85 bool use_shared_memory) { |
| 68 blink::WebExternalTextureMailbox client_mailbox; | 86 blink::WebExternalTextureMailbox client_mailbox; |
| 69 WebExternalBitmapImpl* bitmap = nullptr; | 87 WebExternalBitmapImpl* bitmap = nullptr; |
| 70 | 88 |
| 71 if (use_shared_memory) | 89 if (use_shared_memory) |
| 72 bitmap = AllocateBitmap(); | 90 bitmap = AllocateBitmap(); |
| 73 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { | 91 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 90 if (client_mailbox.allowOverlay) { | 108 if (client_mailbox.allowOverlay) { |
| 91 size = gfx::Size(client_mailbox.textureSize.width, | 109 size = gfx::Size(client_mailbox.textureSize.width, |
| 92 client_mailbox.textureSize.height); | 110 client_mailbox.textureSize.height); |
| 93 } | 111 } |
| 94 | 112 |
| 95 *mailbox = cc::TextureMailbox( | 113 *mailbox = cc::TextureMailbox( |
| 96 name, sync_token, client_mailbox.textureTarget, size, | 114 name, sync_token, client_mailbox.textureTarget, size, |
| 97 client_mailbox.allowOverlay, false); | 115 client_mailbox.allowOverlay, false); |
| 98 } | 116 } |
| 99 mailbox->set_nearest_neighbor(client_mailbox.nearestNeighbor); | 117 mailbox->set_nearest_neighbor(client_mailbox.nearestNeighbor); |
| 118 mailbox->set_color_space(toGfxColorSpace(client_mailbox.colorSpace)); | |
| 100 | 119 |
| 101 if (mailbox->IsValid()) { | 120 if (mailbox->IsValid()) { |
| 102 *release_callback = cc::SingleReleaseCallback::Create( | 121 *release_callback = cc::SingleReleaseCallback::Create( |
| 103 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, | 122 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, |
| 104 this->AsWeakPtr(), | 123 this->AsWeakPtr(), |
| 105 client_mailbox, | 124 client_mailbox, |
| 106 bitmap)); | 125 bitmap)); |
| 107 } | 126 } |
| 108 | 127 |
| 109 return true; | 128 return true; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 132 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); | 151 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); |
| 133 memcpy(available_mailbox.syncToken, sync_token.GetConstData(), | 152 memcpy(available_mailbox.syncToken, sync_token.GetConstData(), |
| 134 sizeof(sync_token)); | 153 sizeof(sync_token)); |
| 135 available_mailbox.validSyncToken = sync_token.HasData(); | 154 available_mailbox.validSyncToken = sync_token.HasData(); |
| 136 if (bitmap) | 155 if (bitmap) |
| 137 layer->free_bitmaps_.push_back(base::WrapUnique(bitmap)); | 156 layer->free_bitmaps_.push_back(base::WrapUnique(bitmap)); |
| 138 layer->client_->mailboxReleased(available_mailbox, lost_resource); | 157 layer->client_->mailboxReleased(available_mailbox, lost_resource); |
| 139 } | 158 } |
| 140 | 159 |
| 141 } // namespace cc_blink | 160 } // namespace cc_blink |
| OLD | NEW |