Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright 2011, The Android Open Source Project
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *  * Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  *  * Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #define LOG_TAG "InspectorCanvas"
     27 #define LOG_NDEBUG 1
     28 
     29 #include "config.h"
     30 #include "InspectorCanvas.h"
     31 
     32 #include "AndroidLog.h"
     33 #include "SkPicture.h"
     34 
     35 namespace WebCore {
     36 
     37 
     38 void InspectorCanvas::setHasText()
     39 {
     40     m_hasText = true;
     41     setHasContent();
     42 }
     43 
     44 void InspectorCanvas::setHasContent()
     45 {
     46     m_hasContent = true;
     47     if (m_hasText) {
     48         // has text. Have to paint properly, so no further
     49         // information is useful
     50         m_picture->abortPlayback();
     51     }
     52 }
     53 
     54 void InspectorCanvas::setIsBackground(const SkPaint& paint)
     55 {
     56     // TODO: if the paint is a solid color, opaque, and the last instruction in
     57     // the picture, replace the picture with simple draw rect info
     58     setHasContent();
     59 }
     60 
     61 void InspectorCanvas::commonDrawBitmap(const SkBitmap& bitmap,
     62                                        const SkIRect* rect,
     63                                        const SkMatrix&,
     64                                        const SkPaint&)
     65 {
     66     setHasContent();
     67 }
     68 
     69 void InspectorCanvas::drawPaint(const SkPaint& paint)
     70 {
     71     setHasContent();
     72 }
     73 
     74 void InspectorCanvas::drawPath(const SkPath&, const SkPaint& paint)
     75 {
     76     setHasContent();
     77 }
     78 void InspectorCanvas::drawPoints(PointMode, size_t,
     79                                  const SkPoint [], const SkPaint& paint)
     80 {
     81     setHasContent();
     82 }
     83 
     84 void InspectorCanvas::drawRect(const SkRect& rect, const SkPaint& paint)
     85 {
     86     if (rect.fLeft == 0
     87             && rect.fTop == 0
     88             && rect.width() >= m_picture->width()
     89             && rect.height() >= m_picture->height()) {
     90         // rect same size as canvas, treat layer as a single color rect until
     91         // more content is drawn
     92         setIsBackground(paint);
     93     } else {
     94         // regular rect drawing path
     95         setHasContent();
     96     }
     97     ALOGV("draw rect at %f %f, size %f %f, picture size %d %d",
     98           rect.fLeft, rect.fTop, rect.width(), rect.height(),
     99           m_picture->width(), m_picture->height());
    100 }
    101 void InspectorCanvas::drawSprite(const SkBitmap& , int , int ,
    102                                  const SkPaint* paint)
    103 {
    104     setHasContent();
    105 }
    106 
    107 void InspectorCanvas::drawText(const void*, size_t byteLength, SkScalar,
    108                                SkScalar, const SkPaint& paint)
    109 {
    110     setHasText();
    111 }
    112 
    113 void InspectorCanvas::drawPosText(const void* , size_t byteLength,
    114                                   const SkPoint [], const SkPaint& paint)
    115 {
    116     setHasText();
    117 }
    118 
    119 void InspectorCanvas::drawPosTextH(const void*, size_t byteLength,
    120                                    const SkScalar [], SkScalar,
    121                                    const SkPaint& paint)
    122 {
    123     setHasText();
    124 }
    125 
    126 void InspectorCanvas::drawTextOnPath(const void*, size_t byteLength,
    127                                      const SkPath&, const SkMatrix*,
    128                                      const SkPaint& paint)
    129 {
    130     setHasText();
    131 }
    132 
    133 } // namespace WebCore
    134