Lines Matching refs:layer
34 LayerRenderer::LayerRenderer(Layer* layer): mLayer(layer) {
41 LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->getFbo());
45 const float width = mLayer->layer.getWidth();
46 const float height = mLayer->layer.getHeight();
71 LAYER_RENDERER_LOGD("Finished rendering into layer, fbo = %d", mLayer->getFbo());
146 const float height = mLayer->layer.getHeight();
182 Layer* LayerRenderer::createLayer(uint32_t width, uint32_t height, bool isOpaque) {
183 LAYER_RENDERER_LOGD("Requesting new render layer %dx%d", width, height);
192 Layer* layer = Caches::getInstance().layerCache.get(width, height);
193 if (!layer) {
194 LOGW("Could not obtain a layer");
198 layer->setFbo(fbo);
199 layer->layer.set(0.0f, 0.0f, width, height);
200 layer->texCoords.set(0.0f, height / float(layer->getHeight()),
201 width / float(layer->getWidth()), 0.0f);
202 layer->setAlpha(255, SkXfermode::kSrcOver_Mode);
203 layer->setBlend(!isOpaque);
204 layer->setColorFilter(NULL);
205 layer->region.clear();
210 glBindFramebuffer(GL_FRAMEBUFFER, layer->getFbo());
211 layer->bindTexture();
214 if (layer->isEmpty()) {
215 layer->setEmpty(false);
216 layer->allocateTexture(GL_RGBA, GL_UNSIGNED_BYTE);
219 LOGD("Could not allocate texture for layer (fbo=%d %dx%d)",
225 layer->deleteTexture();
226 delete layer;
233 layer->getTexture(), 0);
242 return layer;
245 bool LayerRenderer::resizeLayer(Layer* layer, uint32_t width, uint32_t height) {
246 if (layer) {
247 LAYER_RENDERER_LOGD("Resizing layer fbo = %d to %dx%d", layer->getFbo(), width, height);
249 if (Caches::getInstance().layerCache.resize(layer, width, height)) {
250 layer->layer.set(0.0f, 0.0f, width, height);
251 layer->texCoords.set(0.0f, height / float(layer->getHeight()),
252 width / float(layer->getWidth()), 0.0f);
254 layer->deleteTexture();
255 delete layer;
263 Layer* LayerRenderer::createTextureLayer(bool isOpaque) {
264 LAYER_RENDERER_LOGD("Creating new texture layer");
266 Layer* layer = new Layer(0, 0);
267 layer->setCacheable(false);
268 layer->setTextureLayer(true);
269 layer->setBlend(!isOpaque);
270 layer->setEmpty(true);
271 layer->setFbo(0);
272 layer->setAlpha(255, SkXfermode::kSrcOver_Mode);
273 layer->layer.set(0.0f, 0.0f, 0.0f, 0.0f);
274 layer->texCoords.set(0.0f, 1.0f, 1.0f, 0.0f);
275 layer->region.clear();
276 layer->setRenderTarget(GL_NONE); // see ::updateTextureLayer()
279 layer->generateTexture();
281 return layer;
284 void LayerRenderer::updateTextureLayer(Layer* layer, uint32_t width, uint32_t height,
286 if (layer) {
287 layer->setBlend(!isOpaque);
288 layer->setSize(width, height);
289 layer->layer.set(0.0f, 0.0f, width, height);
290 layer->region.set(width, height);
291 layer->regionRect.set(0.0f, 0.0f, width, height);
292 layer->getTexTransform().load(transform);
294 if (renderTarget != layer->getRenderTarget()) {
295 layer->setRenderTarget(renderTarget);
296 layer->bindTexture();
297 layer->setFilter(GL_NEAREST, GL_NEAREST, false, true);
298 layer->setWrap(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false, true);
303 void LayerRenderer::destroyLayer(Layer* layer) {
304 if (layer) {
305 LAYER_RENDERER_LOGD("Recycling layer, %dx%d fbo = %d",
306 layer->getWidth(), layer->getHeight(), layer->getFbo());
308 if (layer->getFbo()) {
309 Caches::getInstance().fboCache.put(layer->getFbo());
312 if (!Caches::getInstance().layerCache.put(layer)) {
314 layer->deleteTexture();
315 delete layer;
321 layer->region.clear();
326 void LayerRenderer::destroyLayerDeferred(Layer* layer) {
327 if (layer) {
328 LAYER_RENDERER_LOGD("Deferring layer destruction, fbo = %d", layer->getFbo());
330 Caches::getInstance().deleteLayerDeferred(layer);
334 bool LayerRenderer::copyLayer(Layer* layer, SkBitmap* bitmap) {
336 if (layer && layer->isTextureLayer() && bitmap->width() <= caches.maxTextureSize &&
376 float alpha = layer->getAlpha();
377 SkXfermode::Mode mode = layer->getMode();
379 layer->setAlpha(255, SkXfermode::kSrc_Mode);
380 layer->setFbo(fbo);
406 LayerRenderer renderer(layer);
409 bitmap->width(), bitmap->height(), !layer->isBlend());
415 mat4 texTransform(layer->getTexTransform());
420 layer->getTexTransform().multiply(invert);
427 renderer.drawTextureLayer(layer, bounds);
435 layer->getTexTransform().load(texTransform);
442 LOGD("GL error while copying layer into bitmap = 0x%x", error);
447 layer->setAlpha(alpha, mode);
448 layer->setFbo(0);