app_server: add new BView layers API

* Add new methods
    BView::BeginLayer(uint8 opacity)
    BView::EndLayer()

* All drawing between begin and end of a layer is redirected onto an
  intermediate bitmap. When ending the layer, this bitmap is
  composited onto the view with the opacity given when the layer was
  started.

* Layers can be nested arbitrarily and will be blended onto each
  other in order. There can also be any arbitrary interleaving of
  layer begin/end and drawing operations.

* Internally, drawing commands are redirected into a BPicture between
  BeginLayer and EndLayer (but client code need not know or care
  about this). Client code can also start/end other BPictures while
  inside a layer.

* Uses the PictureBoundingBoxPlayer to determine the size of the
  layer bitmap before allocating and drawing into it, so it does not
  allocate more memory than necessary and -- more importantly -- it
  will not alpha-composite more pixels than necessary.

* Drawing mode is always set to B_OP_ALPHA, blend mode to
  (B_PIXEL_ALPHA, B_ALPHA_COMPOSITE) while inside layers. This is
  necessary for (a) correct compositing output and (b) for
  redirection of drawing into the intermediate bitmap, which uses the
  renderer_region offset (in B_OP_COPY, the Painter does not use the
  AGG renderer methods, it directly accesses the pixel data. This
  would access out-of-bounds without the offset, so B_OP_COPY cannot
  be allowed.)
  To ensure these modes aren't changed, BView::SetDrawingMode()
  and BView::SetBlendingMode() are ignored while inside a layer.

* The main motivation behind this new API is WebKit, which internally
  expects such a layers functionality to be present. A performant and
  reusable implementation of this functionality can only be done
  server-side in app_server.
This commit is contained in:
Julian Harnath
2015-07-25 16:35:52 +02:00
parent d56beda4d8
commit 551438b9be
19 changed files with 489 additions and 14 deletions
@@ -1,9 +1,10 @@
/*
* Copyright 2006-2007 Haiku, Inc. All rights reserved.
* Copyright 2006-2015 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stefano Ceccherini, [email protected]
* Julian Harnath, <[email protected]>
*/
#ifndef _PICTURE_DATA_WRITER_H
#define _PICTURE_DATA_WRITER_H
@@ -17,6 +18,7 @@
#include <stack>
class Layer;
class BPositionIO;
class BRegion;
@@ -91,6 +93,8 @@ public:
status_t WriteDrawPicture(const BPoint& where,
const int32& token);
status_t WriteBlendLayer(Layer* layer);
protected:
// throw a status_t on error
void BeginOp(const int16& op);
+2 -1
View File
@@ -52,10 +52,11 @@ enum {
B_PIC_SET_FONT_BPP = 0x0388,
B_PIC_SET_FONT_FACE = 0x0389,
B_PIC_SET_TRANSFORM = 0x0390,
B_PIC_BLEND_LAYER = 0x0391
};
const static uint32 kOpsTableSize = 49;
const static uint32 kOpsTableSize = 50;
#endif