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 "cc/blink/web_external_bitmap_impl.h" | 7 #include "cc/blink/web_external_bitmap_impl.h" |
8 #include "cc/blink/web_layer_impl.h" | 8 #include "cc/blink/web_layer_impl.h" |
9 #include "cc/layers/texture_layer.h" | 9 #include "cc/layers/texture_layer.h" |
10 #include "cc/resources/resource_update_queue.h" | 10 #include "cc/resources/resource_update_queue.h" |
11 #include "cc/resources/single_release_callback.h" | 11 #include "cc/resources/single_release_callback.h" |
12 #include "cc/resources/texture_mailbox.h" | 12 #include "cc/resources/texture_mailbox.h" |
13 #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" | 13 #include "third_party/WebKit/public/platform/WebExternalTextureLayerClient.h" |
14 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" | 14 #include "third_party/WebKit/public/platform/WebExternalTextureMailbox.h" |
15 #include "third_party/WebKit/public/platform/WebFloatRect.h" | 15 #include "third_party/WebKit/public/platform/WebFloatRect.h" |
16 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 16 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
17 #include "third_party/WebKit/public/platform/WebSize.h" | 17 #include "third_party/WebKit/public/platform/WebSize.h" |
18 #include "third_party/khronos/GLES2/gl2.h" | 18 #include "third_party/khronos/GLES2/gl2.h" |
19 | 19 |
20 using cc::TextureLayer; | 20 using cc::TextureLayer; |
21 using cc::ResourceUpdateQueue; | 21 using cc::ResourceUpdateQueue; |
22 | 22 |
23 namespace cc_blink { | 23 namespace cc_blink { |
24 | 24 |
25 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( | 25 WebExternalTextureLayerImpl::WebExternalTextureLayerImpl( |
26 blink::WebExternalTextureLayerClient* client) | 26 blink::WebExternalTextureLayerClient* client) |
27 : client_(client) { | 27 : client_(client), |
28 nearest_neighbor_(false) { | |
29 //printf("WebExternalTextureLayerImpl %c\n", (client_ ? '1' : '0')); | |
28 cc::TextureLayerClient* cc_client = client_ ? this : nullptr; | 30 cc::TextureLayerClient* cc_client = client_ ? this : nullptr; |
29 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(cc_client); | 31 scoped_refptr<TextureLayer> layer = TextureLayer::CreateForMailbox(cc_client); |
30 layer->SetIsDrawable(true); | 32 layer->SetIsDrawable(true); |
31 layer_.reset(new WebLayerImpl(layer)); | 33 layer_.reset(new WebLayerImpl(layer)); |
32 } | 34 } |
33 | 35 |
34 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() { | 36 WebExternalTextureLayerImpl::~WebExternalTextureLayerImpl() { |
35 static_cast<TextureLayer*>(layer_->layer())->ClearClient(); | 37 static_cast<TextureLayer*>(layer_->layer())->ClearClient(); |
36 } | 38 } |
37 | 39 |
(...skipping 17 matching lines...) Expand all Loading... | |
55 } | 57 } |
56 | 58 |
57 void WebExternalTextureLayerImpl::setBlendBackgroundColor(bool blend) { | 59 void WebExternalTextureLayerImpl::setBlendBackgroundColor(bool blend) { |
58 static_cast<TextureLayer*>(layer_->layer())->SetBlendBackgroundColor(blend); | 60 static_cast<TextureLayer*>(layer_->layer())->SetBlendBackgroundColor(blend); |
59 } | 61 } |
60 | 62 |
61 void WebExternalTextureLayerImpl::setRateLimitContext(bool rate_limit) { | 63 void WebExternalTextureLayerImpl::setRateLimitContext(bool rate_limit) { |
62 static_cast<TextureLayer*>(layer_->layer())->SetRateLimitContext(rate_limit); | 64 static_cast<TextureLayer*>(layer_->layer())->SetRateLimitContext(rate_limit); |
63 } | 65 } |
64 | 66 |
67 void WebExternalTextureLayerImpl::setFilterLevel( | |
68 SkPaint::FilterLevel filter_level) { | |
69 //printf("WebExternalTextureLayerImpl::setFilterLevel %d\n", filter_level == S kPaint::kNone_FilterLevel); | |
70 nearest_neighbor_ = filter_level == SkPaint::kNone_FilterLevel; | |
71 static_cast<TextureLayer*>(layer_->layer()) | |
72 ->SetNearestNeighbor(nearest_neighbor_); | |
73 } | |
74 | |
65 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( | 75 bool WebExternalTextureLayerImpl::PrepareTextureMailbox( |
66 cc::TextureMailbox* mailbox, | 76 cc::TextureMailbox* mailbox, |
67 scoped_ptr<cc::SingleReleaseCallback>* release_callback, | 77 scoped_ptr<cc::SingleReleaseCallback>* release_callback, |
68 bool use_shared_memory) { | 78 bool use_shared_memory) { |
69 blink::WebExternalTextureMailbox client_mailbox; | 79 blink::WebExternalTextureMailbox client_mailbox; |
70 WebExternalBitmapImpl* bitmap = nullptr; | 80 WebExternalBitmapImpl* bitmap = nullptr; |
71 | 81 |
72 if (use_shared_memory) | 82 if (use_shared_memory) |
73 bitmap = AllocateBitmap(); | 83 bitmap = AllocateBitmap(); |
74 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { | 84 if (!client_->prepareMailbox(&client_mailbox, bitmap)) { |
75 if (bitmap) | 85 if (bitmap) |
76 free_bitmaps_.push_back(bitmap); | 86 free_bitmaps_.push_back(bitmap); |
77 return false; | 87 return false; |
78 } | 88 } |
79 gpu::Mailbox name; | 89 gpu::Mailbox name; |
80 name.SetName(client_mailbox.name); | 90 name.SetName(client_mailbox.name); |
81 if (bitmap) { | 91 if (bitmap) { |
82 *mailbox = cc::TextureMailbox(bitmap->shared_memory(), bitmap->size()); | 92 *mailbox = cc::TextureMailbox(bitmap->shared_memory(), bitmap->size()); |
83 } else { | 93 } else { |
84 *mailbox = | 94 *mailbox = |
85 cc::TextureMailbox(name, GL_TEXTURE_2D, client_mailbox.syncPoint); | 95 cc::TextureMailbox(name, GL_TEXTURE_2D, client_mailbox.syncPoint); |
86 } | 96 } |
87 mailbox->set_allow_overlay(client_mailbox.allowOverlay); | 97 mailbox->set_allow_overlay(client_mailbox.allowOverlay); |
98 mailbox->set_nearest_neighbor(nearest_neighbor_); | |
piman
2014/10/28 05:09:50
This should not be set indiscriminately, but based
jackhou1
2014/10/29 00:12:24
Done.
| |
88 | 99 |
89 if (mailbox->IsValid()) { | 100 if (mailbox->IsValid()) { |
90 *release_callback = cc::SingleReleaseCallback::Create( | 101 *release_callback = cc::SingleReleaseCallback::Create( |
91 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, | 102 base::Bind(&WebExternalTextureLayerImpl::DidReleaseMailbox, |
92 this->AsWeakPtr(), | 103 this->AsWeakPtr(), |
93 client_mailbox, | 104 client_mailbox, |
94 bitmap)); | 105 bitmap)); |
95 } | 106 } |
96 | 107 |
97 return true; | 108 return true; |
(...skipping 18 matching lines...) Expand all Loading... | |
116 DCHECK(layer); | 127 DCHECK(layer); |
117 blink::WebExternalTextureMailbox available_mailbox; | 128 blink::WebExternalTextureMailbox available_mailbox; |
118 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); | 129 memcpy(available_mailbox.name, mailbox.name, sizeof(available_mailbox.name)); |
119 available_mailbox.syncPoint = sync_point; | 130 available_mailbox.syncPoint = sync_point; |
120 if (bitmap) | 131 if (bitmap) |
121 layer->free_bitmaps_.push_back(bitmap); | 132 layer->free_bitmaps_.push_back(bitmap); |
122 layer->client_->mailboxReleased(available_mailbox, lost_resource); | 133 layer->client_->mailboxReleased(available_mailbox, lost_resource); |
123 } | 134 } |
124 | 135 |
125 } // namespace cc_blink | 136 } // namespace cc_blink |
OLD | NEW |